iOS将GIF转变为图片
2016-03-07 15:01
387 查看
import UIKit import ImageIO class Tools: NSObject { class func parseGIFDataToImageArray(data: NSData) -> [UIImage]{ var images: [UIImage] = [] let src = CGImageSourceCreateWithData(data as CFDataRef,nil) var animationTime: CGFloat = 0.8 if let src = src { let total = CGImageSourceGetCount(src) for var i = 0;i < total;i++ { let img = CGImageSourceCreateImageAtIndex(src, i, nil) let properties = CGImageSourceCopyPropertiesAtIndex(src, i, nil)! as Dictionary let imageProperties = properties[kCGImagePropertyGIFDictionary as String]! let delayTime = imageProperties[kCGImagePropertyGIFUnclampedDelayTime as String] as! NSNumber animationTime += CGFloat(delayTime) if let img = img { images.append(UIImage(CGImage: img)) } } print("time=\(animationTime)") } return images } }
相关文章推荐
- iOS获取字符串高度
- iOS 设备定位功能可用的判断
- IOS 获取设备机型 系统版本 应用版本
- iOS pod install update 慢!!!
- IOS的变量修饰词@public 、@protected、@package、@private,简称 4P
- IOS学习 scrollView的基本属性
- iOS7 tableview separatorInset cell分割线左对齐
- 【Xamarin挖墙脚系列:IOS-关于手机支持的屏幕方向】
- 【Xamarin挖墙脚系列:Xamarin.IOS机制原理剖析】
- iOS开发有关Core Animation的介绍
- iOS-触摸事件
- iOS多线程
- 【Xamarin挖墙脚系列:Xamarin.IOS的程序的结构】
- IOS中对Url进行编码和解码
- 【Xamarin 挖墙脚系列:IOS 开发界面的3种方式】
- ios googlemaps 开发 设置地图可见所有大头针
- iOS打包,证书配置等
- IOS常用第三方库
- iphone ios 和pc间通过wifi通讯,连接
- iOS项目统计代码行数