首页 > 编程语言 > 详细

Swift实现截屏并保存相册

时间:2016-10-12 19:17:06      阅读:481      评论:0      收藏:0      [点我收藏+]
 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实现截屏并保存相册

原文:http://www.cnblogs.com/yajunLi/p/5953966.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!