How do I make a snapshot without the navigation bar in iOS with Swift?

戏子无情 提交于 2019-12-04 20:56:46

If you change the layer you are attempting to screenshot from the keyWindow's view to your view controller's view, the navigation bar (assuming you have your view controller embedded in a navigation controller rather than adding a nav bar as a subview of your view) and the status bar will be omitted from the screenshot.

let layer = view.layer

If you have blank space at the top where the navigation bar was, you can adjust the frame to cut this out.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!