_UIReplicantView和snapshotViewAfterScreenUpdates如何获取其内容? [英] _UIReplicantView and snapshotViewAfterScreenUpdates how to get its content?

查看:816
本文介绍了_UIReplicantView和snapshotViewAfterScreenUpdates如何获取其内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-renderInContext:自出现以来就被广泛使用,但由于无法渲染OpenGL层,AVPreviewLayer(可能因为是某种OpenGL层)而且我仍然无法正确呈现CATiledLayer。

在iOS7中引入了2个新的API来获取屏幕截图,一个是 -snapshotViewAfterScreenUpdates:,它返回一个特定的视图( _UIReplicantView )和 -drawViewHierarchyInRect:afterScreenUpdates:最后一个是 -renderInContext 的替代品不幸的是,它似乎也有同样的局限性。

-snapshotViewAfterScreenUpdates:它似乎也适用于OpenGL和AVPreviewLayer,不幸的是,如果你想做特定的动画或使用内容作为某些东西的背景(如uibutton),这样的视图不是很有用)。我试图从返回的视图中删除内容,但我仍然没有运气。

有人试过吗?

-renderInContext: has been used widely since its appearance, but with it is impossible to render OpenGL layer, AVPreviewLayer (probably because is a sort of OpenGL layer) and I still wasn't able to render a CATiledLayer correctly.
With iOS7 were introduced 2 new APIs to get screenshots, one is -snapshotViewAfterScreenUpdates: that returns a particular view (_UIReplicantView) and -drawViewHierarchyInRect:afterScreenUpdates: the last one is a sort of replacement for -renderInContext, unfortunately it seems to have the same limitations.
The -snapshotViewAfterScreenUpdates: it seems to work also with OpenGL and AVPreviewLayer, unfortunately a view like that is not very useful if you want to do particular animations or use the contents as background of something (such as a uibutton). I've tried to get the contents off from the returned view, but I still get no luck.
Has somebody tried yet?

推荐答案

我一直在努力解决这个问题,最初我们通过挂钩进入NSRunLoop并渲染到图像来解决它将它们合并在一起。这真是一团糟。

I have struggled with exactly this issue, initially we worked around it by hooking into the NSRunLoop and rendering to an image and then merging them together. It was really messy.

然后我们发现了一段似乎可以解决这个问题的代码,但是你必须准备好在盒子外思考一下。

Then we found a piece of code that would appear to solve this issue, but you have to be prepared to think outside the box a little bit.

该框架记录了一个UIWindow的视频,然后我们就停止了记录。把它推到AVAssetImageGenerator(或类似的东西),然后把图像拿出来。

That framework records a video of a UIWindow, we were then just stopping the record. Shoving it through a AVAssetImageGenerator (or something like that), and grabbing the image out.

正如我所说,解决它是一种非常奇怪的方式,但它似乎我们工作还可以。

As I say it's very much a weird way to solve it, but it seems to work okay for us.

此库中可以找到(ASScreenRecorder)的代码。

The code for (ASScreenRecorder) can be found in this library here.

< a href =https://github.com/alskipp/ASScreenRecorder =nofollow> https://github.com/alskipp/ASScreenRecorder

我们产品中的一个菜单是OpenGL,有些还有视频背景!这对我们来说非常有效。但是我不能确定它是否是我们实现和使用OpenGL的特别之处。尽管如他的视频节目所示,它确实适用于相机视图。

One of our menu's in our product was OpenGL and some had video backgrounds! And this worked perfectly for us. But I cant be sure if it was something particular to our implementation and use of OpenGL. It definitely does work for camera views though as his example video's show.

这篇关于_UIReplicantView和snapshotViewAfterScreenUpdates如何获取其内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆