Ios 在Swift中创建动画gif时出现问题
我正试图从Swift中的4个Ios 在Swift中创建动画gif时出现问题,ios,swift,gif,Ios,Swift,Gif,我正试图从Swift中的4个UIImage元素数组中创建一个动画gif,但目前它只保存第一帧 let url = NSURL(fileURLWithPath: photosDirectory)?.URLByAppendingPathComponent(filename()) if let url = url { let fileProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopC
UIImage
元素数组中创建一个动画gif,但目前它只保存第一帧
let url = NSURL(fileURLWithPath: photosDirectory)?.URLByAppendingPathComponent(filename())
if let url = url {
let fileProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopCount as String: 0]]
let gifProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFDelayTime as String: 0.125]]
let destination = CGImageDestinationCreateWithURL(url, kUTTypeGIF, photos.count, nil)
CGImageDestinationSetProperties(destination, fileProperties)
for photo in photos {
CGImageDestinationAddImage(destination, photo.CGImage, gifProperties)
}
return CGImageDestinationFinalize(destination)
}
else {
return false
}
photos
是ui图像的数组
filename()
只返回类似于20150805.gif的字符串
它返回true,但只有第一帧在gif中
应该是浮动的,而不是双重的
尝试设置0.125f而不是0.125不相关;它变成了一个NSNumber
,所以没有实际的区别。哇,我收回了。在iOS 8.2上,这很重要!我不知道ImageIO是怎么做到的。在iOS 8.3及更高版本上,Double
非常好。