其实我已经进步了...
我正在设置这样的选项:
var imageProperties:NSMutableDictionary = NSMutableDictionary()
imageProperties.setObject(NSNumber(float: 0.1), forKey: kCGImagePropertyGIFDelayTime as NSString)
imageProperties.setObject(NSNumber(bool: false), forKey: kCGImagePropertyHasAlpha as NSString)
imageProperties.setObject(NSString(string: "kUTTypeGIF"), forKey: kCGImageSourceTypeIdentifierHint as NSString)
imageProperties.setObject(NSNumber(bool: false), forKey: kCGImagePropertyGIFImageColorMap as NSString)
imageProperties.setObject(NSNumber(bool: true), forKey: kCGImageSourceShouldCache as NSString)
let nestedImageProperties:NSDictionary = [imageProperties: kCGImagePropertyGIFDictionary]
println("nestedImageProperties: \(nestedImageProperties)")
这给了我这个结构:
nestedImageProperties: {
{
DelayTime = "0.1";
HasAlpha = 0;
ImageColorMap = 0;
kCGImageSourceShouldCache = 1;
kCGImageSourceTypeIdentifierHint = kUTTypeGIF;
} = "{GIF}";
}
我找到了一个定义如下属性的实现:
let fileProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopCount as String: 0]]
let frameProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFDelayTime as String: 1.0]]
给出这个结构:
Frame Properties: [{GIF}: [DelayTime: 1.0]]
File Properties: [{GIF}: [LoopCount: 0]]
然后我将 fileProperties 应用到目的地:
CGImageDestinationSetProperties(destination, fileProperties as CFDictionaryRef)
以及添加每个图像的 frameProperties:
CGImageDestinationAddImage(destination, imageRef, frameProperties as CFDictionaryRef)
最后,它正在起作用,它们正在被应用。
还没有尝试过多个属性,但应该没问题。