CALayer renderInContext

har*_*ara 6 core-animation calayer

我用

CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -500;
Run Code Online (Sandbox Code Playgroud)

这是成功的,但我使用"renderInContext:context"从上下文中获取CGImage,我发现图像效果没有改变!

如何从CALayer获得此效果图像?

Mar*_*rov 2

我的原始回复如下。它在我发布时有效,但 Apple 不允许再使用 UIGetScreenImage。据我所知,在 iOS4 发布后,没有其他方法可以使用 3D 转换来渲染图层 + 如果您使用 UIGetScreenImage 您的应用程序将被拒绝



来自 iPhone 开发人员文档中的 renderInContext :

此外,不会渲染使用 3D 变换的图层,也不会渲染指定背景过滤器、过滤器、compositingFilter 或遮罩值的图层。

因此,renderInContext 不是渲染应用了 3D 变换的图层所需的函数。

你能做的最好的事情就是调用:UIGetScreenImage,它基本上会给你一个屏幕截图,然后你可以从这个屏幕截图中提取图像。

  • 不再允许使用 UIGetScreenImage。我刚刚收到一封来自 Apple 的电子邮件,要求停止使用此私有函数并使用 -renderInContext:(在 iOs 3.x 上)或 AV Foundation AVCaptureSession 和相关类(在 iOS 4 上)。 (2认同)