在不使用 UIWebview 的情况下显示 gif 图像 [重复]

Posted

技术标签:

【中文标题】在不使用 UIWebview 的情况下显示 gif 图像 [重复]【英文标题】:Display gif image without using UIWebview [duplicate] 【发布时间】:2014-10-07 18:12:06 【问题描述】:

在我的应用程序中,我需要在我的视图上显示 gif 图像,但不要使用 UIWebview 来显示它。那么有什么办法吗?提前致谢!

【问题讨论】:

看看这个:-github.com/arturogutierrez/Animated-GIF-iPhone 这里有同样的问题:- ***.com/questions/9744682/display-animated-gif-in-ios 【参考方案1】:

看看这个

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

它提供以下类别:

+[UIImage animatedImageWithAnimatedGIFURL:(NSURL *)url]

让你简单地:

#import "UIImage+animatedGIF.h"
UIImage* mygif = [UIImage animatedImageWithAnimatedGIFURL:[NSURL URLWithString:@"http://en.wikipedia.org/wiki/File:Rotating_earth_(large).gif"]];

【讨论】:

【参考方案2】:

你可以使用来自 gothub 的这个项目 https://github.com/mayoff/uiimage-from-animated-gif

例子

NSURL *url = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"gif"];
self.dataImageView.image = [UIImage animatedImageWithAnimatedGIFData:[NSData dataWithContentsOfURL:url]];
self.urlImageView.image = [UIImage animatedImageWithAnimatedGIFURL:url];

url = [[NSBundle mainBundle] URLForResource:@"variableDuration" withExtension:@"gif"];
self.variableDurationImageView.image = [UIImage animatedImageWithAnimatedGIFURL:url];

【讨论】:

对好的链接投赞成票,所以只有答案是接受,所以这必须是较早的答案。感谢您的帮助。

以上是关于在不使用 UIWebview 的情况下显示 gif 图像 [重复]的主要内容,如果未能解决你的问题,请参考以下文章