我正在尝试使用以下代码将GIF从URL保存到相机胶卷:
var image = UIImage(data: NSData(contentsOfURL: self.imageView.sd_imageURL())!)
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
但保存后,GIF成为静止图像,任何人都可以帮助我吗? 谢谢!
答案 0 :(得分:0)
试试这个:
import AssetsLibrary
let image = NSData(contentsOfURL: url)
ALAssetsLibrary().writeImageDataToSavedPhotosAlbum(image, metadata: nil, completionBlock: { (assetURL: NSURL!, error: NSError!) -> Void in
print(assetURL)
})
答案 1 :(得分:0)
您可以通过PHPhotoLibrary保存GIF
PHPhotoLibrary.shared().performChanges({
let request = PHAssetCreationRequest.forAsset()
request.addResource(with: .photo, fileURL: YOUR_GIF_URL, options: nil)
}) { (success, error) in
if let error = error {
completion(.failure(error))
} else {
completion(.success(true))
}
}