take screen Programmatically of UIview+glview

前端 未结 2 1190
温柔的废话
温柔的废话 2021-01-16 23:51

i have glview in my uiview ,now i have to take scrren shot of combine view of uiview and glview. i googled lot but i dnt found any thing useful i know how to take scrrenshot

2条回答
  •  被撕碎了的回忆
    2021-01-17 00:19

    It seems like it's pretty tricky to get a screenshot nowadays, especially when you're mixing the UIKit and OpenGL ES: there used to be UIGetScreenImage() but Apple made it private again and is rejecting apps that use it.

    Instead, there are two "solutions" to replace it: Screen capture in UIKit applications and OpenGL ES View Snapshot. The former does not capture OpenGL ES or video content while the later is only for OpenGL ES.

    There is another technical note How do I take a screenshot of my app that contains both UIKit and Camera elements?, and here they essentially say: You need to first capture the camera picture and then when rendering the view hierarchy, draw that image in the context.

    The very same would apply for OpenGL ES: You would first need to render a snapshot for your OpenGL ES view, then render the UIKit view hierarchy into an image context and draw the image of your OpenGL ES view on top of it. Very ugly, and depending on your view hierarchy it might actually not be what you're seeing on screen (e. g. if there are views in front of your OpenGL view).

提交回复
热议问题