ios播放gif动画
来源:互联网 发布:剑三花爹数据 编辑:程序博客网 时间:2024/05/21 04:24
#import <ImageIO/ImageIO.h>
NSData *gifData = [NSData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@“xxx” ofType:@"gif"]];
NSMutableArray *frames = nil;
CGImageSourceRef src = CGImageSourceCreateWithData((CFDataRef)gifData, NULL);
double total = 0;
NSTimeInterval gifAnimationDuration;
if (src) {
size_t l = CGImageSourceGetCount(src);
if (l > 1){
frames = [NSMutableArray arrayWithCapacity: l];
for (size_t i = 0; i < l; i++) {
CGImageRef img = CGImageSourceCreateImageAtIndex(src, i, NULL);
NSDictionary *dict = (NSDictionary *)CFBridgingRelease(CGImageSourceCopyPropertiesAtIndex(src, 0, NULL));
if (dict){
NSDictionary *tmpdict = [dict objectForKey: @"{GIF}"];
total += [[tmpdict objectForKey: @"DelayTime"] doubleValue] * 100;
}
if (img) {
[frames addObject: [UIImage imageWithCGImage: img]];
CGImageRelease(img);
}
}
gifAnimationDuration = total / 100;
UIImageView *imageView = [[UIImageView alloc] init];
imageView.animationImages = frames;
imageView.animationDuration = gifAnimationDuration;
[imageView startAnimating];
imageView.frame=CGRectMake((i-1)*[UIScreen mainScreen].bounds.size.width, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
[pageContairView addSubview:imageView];
}
}
- iOS 播放gif 动画
- iOS Gif动画播放
- ios播放gif动画
- iOS 播放GIF动画
- ios中播放gif动画
- ios中播放gif动画
- iOS中播放gif动画
- ios中播放gif动画
- ios中播放gif动画
- ios中播放gif动画
- ios中播放gif动画
- ios中播放gif动画
- iOS 简单实现gif动画播放
- cocoa ios iphone xcode 播放GIF动画
- iOS 简单的播放gif动画
- iOS 简单的播放gif动画
- iOS 简单实现gif动画播放
- iOS之GIF动画文件的播放
- iOS项目开发实战——UILabel与取色器的使用
- 浅谈 Html && Css && JavaScript(1)
- Android 设置background(seletor)无效
- Centos7 安装Cobbler
- (转)Android之值得开发者(安卓)必备的十八大开发资源
- ios播放gif动画
- 遍历Map的四种方法
- huawei机试
- (一二九)获取文件的MineType、利用SSZipArchive进行压缩解压
- OGNL表达式struts2标签“%,#,$”
- 【算法C++】十进制字符串转十六进制字符串
- C#实现多线程
- 解决IE8以上乱码
- 两个数据库进行数据比对(DataTable对比)