2013-03-19 37 views
1

我有一个gif图像文件有4个图像,我喜欢在UIImage视图中逐一显示这些图像image.animation。请指导是否有可能显示或使用alternat告诉我。如何在UIImageView中使用gif图像iOS

谢谢。

+2

欢迎...发布提问http://stackoverflow.com/questions/9744682/display-animated-gif-in-ios – 2013-03-19 09:26:30

+0

谢谢之前,请做好搜索Lithu非常多你得到了我的问题点。 – Youaregreat 2013-03-19 09:42:32

回答

3

FLAnimatedImage是为iOS一个高性能的开源动画GIF发动机:

  • 播放多个与重放速度同时的GIF可比 到桌面浏览器
  • 荣誉可变帧延迟
  • 内存压力下正常行为不
  • 消除第一个播放循环中的延迟或阻塞
  • 解释帧d与现代浏览器一样,使用快速GIFs

这是一个经过良好测试的组件,我写信给power all GIFs in Flipboard

+0

可悲的是,这个吊舱已经9个月没有维持。 – mxcl 2017-02-13 21:53:43

0

尝试像这样...所有的

- (void)viewDidLoad { 
     [super viewDidLoad]; 

     NSURL *url = [[NSBundle mainBundle] URLForResource:@"loading" withExtension:@"gif"]; 
     UIImage *loadingImage = [UIImage animatedImageWithAnimatedGIFData:[NSData dataWithContentsOfURL:url]]; 
     self.dataImageView.animationImages = loadingImage.images; 
     self.dataImageView.animationDuration = loadingImage.duration; 
     self.dataImageView.animationRepeatCount = 1; 
     self.dataImageView.image = loadingImage.images.lastObject; 
     [self.dataImageView startAnimating]; 
    } 
0

首先,你可以添加在一个plist中的4张图片,然后执行以下代码。我希望它会工作

NSDictionary *picturesDictionary = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"PhotesArray" ofType:@"plist"]]; 
NSArray *imageNames = [picturesDictionary objectForKey:@"Photos"]; 
NSMutableArray *images = [[NSMutableArray alloc] init]; 
for (int i=0; i<[imageNames count]; i++) { 
    [images addObject:[UIImage imageNamed:[imageNames objectAtIndex:i]]]; 
} 
//Normal animation 
self.dataImageView.animationImages = images; 
self.dataImageView.animationDuration = 3.0; 
[self.dataImageView startAnimating]; 
相关问题