Probleme beim Erstellen eines animierten Gifs in Swift
Ich versuche ein animiertes GIF aus einem Array von 4 zu erstellenUIImage
-Elemente in Swift, aber derzeit wird nur der erste Frame gespeichert.
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
ist das Array vonUIImages
filename()
gibt nur einen String wie @ zurü20150805.gif
It gibt true zurück, aber nur der erste Frame befindet sich im gif