问题
I'm traing to save a GIF image located in temp file already created with Regift code.
Regift: https://github.com/matthewpalmer/Regift
The thing is that after saving with PHPhotoLibrary the GIF become a still image.
In other questions there's answers that refeer AssetsLibrary but this has been deprecated by Apple and doesn't work for iOS 10.
Questions:
Save GIF image from URL to Camera Roll
How to write animated GIF to iOS camera roll?
None of this answers works... I just want to convert an image to gif and save it to camera roll... Any help?
Thanks
回答1:
You can save GIF via PHPhotoLibrary.
PHPhotoLibrary.shared().performChanges({
let request = PHAssetCreationRequest.forAsset()
request.addResource(with: .photo, fileURL: 'YOUR_GIF_URL', options: nil)
}) { (success, error) in
if let error = error {
print(error.localizedDescription)
} else {
print("GIF has saved")
}
}
回答2:
Gif can be save through Activity ViewController. Give url in activity controller and save through that you will get gif in camera roll [https://www.youtube.com/watch?v=-DdXUIjuAk0&feature=youtu.be]
let activityViewController = UIActivityViewController(
activityItems: [url],
applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = view
activityViewController.popoverPresentationController?.sourceRect = view.frame
present(activityViewController, animated: true, completion: nil)
来源:https://stackoverflow.com/questions/43927287/save-gif-to-ios-photo-library-in-swift