在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
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) } }
swift3 截屏 func getScreenImage() -> UIImage { //截屏 let screenRect = UIScreen.main.bounds UIGraphicsBeginImageContext(screenRect.size) let ctx:CGContext = UIGraphicsGetCurrentContext()! self.view.layer.render(in: ctx) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext(); return image! }
|
请发表评论