将URL中的GIF图像保存到相机胶卷 [英] Save GIF image from URL to Camera Roll

查看:108
本文介绍了将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))
        }
    }

这篇关于将URL中的GIF图像保存到相机胶卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆