进入我的应用程序我需要在我的视图上显示gif图像,但不要使用UIWebview来显示它。那有什么办法吗?提前谢谢!
答案 0 :(得分:2)
看看这个
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"]];
答案 1 :(得分: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];