所要截屏的view为
bg_view: UIView!
以截取该bg_view所在的区域为例,截取保存代码如下
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)
利用swift内置库生成的二维码无法直接保存到本地,我是直接截屏保存的,有其他解决办法望告知
网友评论