如何在UIImageView iOS中使用gif图像

时间:2013-03-19 09:23:49

标签: iphone image uiimageview show

我有一个有4个图像的gif图像文件,我喜欢在UIImage视图中逐个显示这些图像的image.animation。请指导是否可以显示或使用替代告诉我。

谢谢你。

5 个答案:

答案 0 :(得分:3)

FLAnimatedImage是适用于iOS的高性能开源动画GIF引擎:

  • 同时播放多个GIF,播放速度可比 到桌面浏览器
  • 尊重可变帧延迟
  • 在记忆压力下表现优雅
  • 在第一个播放循环期间消除延迟或阻止
  • 以与现代浏览器相同的方式解释快速GIF的帧延迟

这是我写给power all GIFs in Flipboard的经过充分测试的组件。

答案 1 :(得分:1)

它会帮助你,对于gif链接.. https://github.com/mayoff/uiimage-from-animated-gif更多的帮助请随时询问

答案 2 :(得分:0)

是的,有可能在iOS中,我在这里附上一个URL。请参考这个概念,即使我是借助此链接做到的。

https://github.com/mayoff/uiimage-from-animated-gif

希望我能帮助你。

答案 3 :(得分: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];
    }

答案 4 :(得分:0)

首先,您可以将这4个图像添加到一个Plist中,并执行以下代码。我希望它能起作用

    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];