【发布时间】:2017-08-21 08:01:22
【问题描述】:
我有一个 gif 图片url 并想将其下载到文档目录中,为此我尝试过使用
if let gifImageData = UIImagePNGRepresentation(image!) {
try gifImageData.write(to: fileURL, options: .atomic)
}
还有
if let jpegImageData = UIImageJPEGRepresentation(image!, 1.0) {
try jpegImageData.write(to: fileURL, options: .atomic)
}
但此图像保存为单个 png/jpg 图像而不是动画 gif
有什么解决办法吗?
【问题讨论】:
-
您不应使用
UIImagePNGRepresentation和UIImageJPEGRepresentation。只需保存数据。喜欢 Baig 的回答 -
这只是通过下载数据写入。