网上的教程都比较早,分享一下swift3.0的
@IBAction func saveLingfuImage(_ sender: UIBarButtonItem) {
let customImage = UIImage(named: (lingfu?.image)!)
UIImageWriteToSavedPhotosAlbum(customImage!, self, #selector(savedOK(image:didFinishSavingWithError:contextInfo:)), nil)
//UIImageWriteToSavedPhotosAlbum(image!, nil, nil, nil)
}
// 提示:参数 空格 参数别名: 类型
func savedOK(image: UIImage, didFinishSavingWithError error: NSError?, contextInfo: AnyObject) {
print("---")
// if didFinishSavingWithError != nil {
if error != nil {
UIAlertView(title: "错误", message: error?.localizedDescription, delegate: nil, cancelButtonTitle: "确定").show()
return
}
print("OK")
UIAlertView(title: "提示", message: "保存成功", delegate: nil, cancelButtonTitle: "确定").show()
}
网友评论