Problemas al crear un gif animado en Swift
Estoy tratando de crear un gif animado a partir de una matriz de 4UIImage
elementos en Swift pero actualmente solo guarda el primer fotograma.
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
es la matriz deUIImages
filename()
solo devuelve una cadena como20150805.gif
Devuelve verdadero pero solo el primer fotograma está en el gif