swift3.0 屏幕截圖並且保存到本地相冊


所要截取的對象

var bg_view: UIView!

截取並且保存的代碼如下

UIGraphicsBeginImageContextWithOptions(bg_view.frame.size, false, UIScreen.main.scale)
bg_view.layer.render(in: UIGraphicsGetCurrentContext()!)
        
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
        
UIImageWriteToSavedPhotosAlbum(image!,self,#selector(image(_:didFinishSavingWithError:contextInfo:)), nil)

結束!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM