【发布时间】:2014-10-07 18:12:06
【问题描述】:
在我的应用程序中,我需要在我的视图上显示 gif 图像,但不要使用 UIWebview 来显示它。那么有什么办法吗?提前致谢!
【问题讨论】:
标签: ios objective-c iphone gif
在我的应用程序中,我需要在我的视图上显示 gif 图像,但不要使用 UIWebview 来显示它。那么有什么办法吗?提前致谢!
【问题讨论】:
标签: ios objective-c iphone gif
看看这个
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"]];
【讨论】:
你可以使用来自 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];
【讨论】: