试图在图像中没有导航/状态栏的情况下将屏幕截图进行屏幕截图-Swift 3,Xcode 8,iOS



使用:swift 3,xcode 8,ios

我的屏幕截图工作正常,我只需要从相机卷中的图像中省略导航栏即可。这就是我到目前为止的:

@IBAction func buttonAction(_ sender: UIButton) {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, UIScreen.main.scale)
view.layer.render(in: UIGraphicsGetCurrentContext()!)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
UIImageWriteToSavedPhotosAlbum(image!, nil, nil, nil)        
}

只需在保存之前裁剪状态栏似乎是理想的解决方案。这是与某人这样做的另一篇文章。

最新更新