Convert a UIImage into NSData BUT stay as a GIF file
问题 I have a UIImage which is a GIF file. I need to make it make it into an NSData object. But it needs to stay a GIF so I can't use UIImageJPEGRepresentation. Any ideas? 回答1: I faced the same issue you mention and here is the code i used to save the animated gif to Photos without losing animation: ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; NSData *data = [NSData dataWithContentsOfURL:[self getCurrentGIFURL]]; [library writeImageDataToSavedPhotosAlbum:data metadata:nil