前端之家收集整理的这篇文章主要介绍了
swift 保存图片到相册,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@objc private func saveBtnClick() {
// 1.获取当前正在显示的image
let cell = collectionView.visibleCells().first as! PhotoBrowserViewCell
guard let image = cell.imageView.image else {
return
}
// 2.将image对象保存相册
UIImageWriteToSavedPhotosAlbum(image,self,"image:didFinishSavingWithError:contextInfo:",nil)
}
@objc private func image(image : UIImage,didFinishSavingWithError error : NSError?,contextInfo : AnyObject) {
var showInfo = ""
if error != nil {
showInfo = "保存失败"
} else {
showInfo = "保存成功"
}
}
原文链接:https://www.f2er.com/swift/323181.html