首先想到的是 UIInageView 播放图片数组。
- (void)gif_imageView {
UIImageView *gifImageView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
NSArray *gifArray = @[[UIImage imageNamed:@"1"],
[UIImage imageNamed:@"2"],
[UIImage imageNamed:@"3"],
[UIImage imageNamed:@"4"],
[UIImage imageNamed:@"5"],
[UIImage imageNamed:@"6"]];
gifImageView.animationImages = gifArray; //动画图片数组
gifImageView.animationDuration = 5; //执行一次完整动画所需的时长
gifImageView.animationRepeatCount = 1; //动画重复次数
[gifImageView startAnimating];
[self.view addSubview:gifImageView];
}
UIWebView 播放
- (void)gif_webView {
// 设定位置和大小
CGRect frame = CGRectMake(11,11,0,0);
frame.size = [UIImage imageNamed:@"test.gif"].size;
// 读取gif图片数据
NSData *gif = [NSData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"test" ofType:@"gif"]];
// view生成
UIWebView *webView = [[UIWebView alloc] initWithFrame:frame];
webView.userInteractionEnabled = NO;//用户不可交互
[webView loadData:gif MIMEType:@"image/gif" textEncodingName:@"12" baseURL:[NSURL URLWithString:@"www.baidu.com"]];
[self.view addSubview:webView];
}
c 解析gif 分段播放 && 转换成一组 png 图片
http://www.cnblogs.com/smileEvday/archive/2013/03/28/Gif.html
代码就不抄袭了。
SvGifView ,不行就百度下他写的demo 吧。