Swift实现截屏并保存相册
Posted 纠结的哈士奇
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Swift实现截屏并保存相册相关的知识,希望对你有一定的参考价值。
func saveToLocal() { //截屏 let screenRect = UIScreen.mainScreen().bounds UIGraphicsBeginImageContext(screenRect.size) let ctx:CGContextRef = UIGraphicsGetCurrentContext()! self.view.layer.renderInContext(ctx) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext(); //保存相册 UIImageWriteToSavedPhotosAlbum(image!, self, "image:didFinishSavingWithError:contextInfo:", nil) } func image(image:UIImage,didFinishSavingWithError error:NSError?,contextInfo:AnyObject) { if error != nil { K12ProgressHUD.showError("保存失败", view: self.view) } else { K12ProgressHUD.showSucess("保存成功", view: self.view) } }
以上是关于Swift实现截屏并保存相册的主要内容,如果未能解决你的问题,请参考以下文章