NSURL *fileUrl = [[NSBundle mainBundle] URLForResource:@"1" withExtension:@"gif"];
CGImageSourceRef gifSource = CGImageSourceCreateWithURL((CFURLRef)fileUrl, NULL);
size_t frameCout=CGImageSourceGetCount(gifSource);
NSMutableArray* frames=[[NSMutableArray alloc] init];
for (size_t i=0; i
CGImageRef imageRef=CGImageSourceCreateImageAtIndex(gifSource, i, NULL);
UIImage* imageName=[UIImage imageWithCGImage:imageRef];
[frames addObject:imageName];
CGImageRelease(imageRef);
}
UIImageView* imageview=[[UIImageView alloc] initWithFrame:CGRectMake(20, 64, 40, 40)];
imageview.animationImages=frames;
imageview.animationDuration=3;
[imageview startAnimating];
[self.view addSubview:imageview];
(转自)http://blog.sina.com.cn/s/blog_8ded6a080102v4ux.html