将URL中的GIF图像保存到相机胶卷

问题描述:

我正在尝试使用以下代码将GIF从URL保存到相机胶卷:

I'm trying to save a GIF from URL to Camera Roll with the following code:

var image = UIImage(data: NSData(contentsOfURL: self.imageView.sd_imageURL())!)
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)

但是保存后,GIF变成了静止图像,有人可以帮助我吗? 谢谢!

but after saving, the GIF become a still image, anyone can help me? Thanks!

您可以通过PHPhotoLibrary保存GIF

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 {
            completion(.failure(error))
        } else {
            completion(.success(true))
        }
    }