" renderInContext:"和CATransform3D [英] "renderInContext:" and CATransform3D

查看:145
本文介绍了" renderInContext:"和CATransform3D的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个视图,里面有多个视图,还有一个图像演示文稿(又名'cover flow'),我也需要以编程方式制作截图!



由于文档说renderInContext:不会渲染3d动画:
$ b 重要此方法的Mac OS X v10.5实现不支持整个Core Animation组合模型,不渲染QCCompositionLayer,CAOpenGLLayer和QTMovieLayer图层,此外,使用3D变换的图层不会被渲染,也不会渲染指定backgroundFilters,filters,compositingFilter或mask值的图层。 OS X可能会添加对呈现这些图层和属性的支持。



来源: https://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CALayer_class/Introduction ction / Introduction.html



我搜索了很多东西,而我的'最好'解决方案(那根本不好)是创建我自己的CGContext并将所有CG动画录制到它中。但我真的不想这样做,因为我需要重写大部分动画代码,并且这对内存来说会非常昂贵......我发现其他解决方案(其中一些无法制作)使用openGL或通过捕获AVSessions,但没有人可以帮助我......



我有什么选择?任何有这个问题的人?



感谢您的宝贵时间!

解决方案

我得到它与协议工作....我在所有 UIViews 类进行3D变换的协议。所以当我请求截图的时候,它会让所有的子视图截图,并生成一个UIImage。对于很多视图来说不是那么好,但是我在几个视图中做。

  #pragma mark  - 协议实现'TDITransitionCustomTransform'

//符合TDITransitionCustomTransform协议,返回当前图层的当前图层视图状态

- (UIImage *)imageForCurrentState {

//打印

UIGraphicsBeginImageContextWithOptions(self.bounds.size,NO,0.0);

[self.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage * screenShot = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

//返回印刷图像

返回screenShot;

}

我认为现在可能有效,因为我在做在转换后的视图图层中呈现,它们正在转换它自己...
它不起作用,因为renderInContext:没有得到它的子视图的层次,可能吗?$ / $>

任何人对这个解决方案的更多代码感兴趣的地方都可以找到这里。在苹果开发论坛。



它可能是一个函数错误,或者它只是没有为此设计...


I have an view that have mutiples views inside it, and an image presentation (aka. 'cover flow') into that too... And I need to make a screenshot programatically !

Since docs says that "renderInContext:" will not render 3d animations :

"Important The Mac OS X v10.5 implementation of this method does not support the entire Core Animation composition model. QCCompositionLayer, CAOpenGLLayer, and QTMovieLayer layers are not rendered. Additionally, layers that use 3D transforms are not rendered, nor are layers that specify backgroundFilters, filters, compositingFilter, or a mask values. Future versions of Mac OS X may add support for rendering these layers and properties."

source: https://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CALayer_class/Introduction/Introduction.html

I have searched a lot, and my 'best' solution (that is not good at all), is to create my own CGContext and record all CG animations into it. But I really do not want to do it, because I will need to re-write most of my animations codes and it will be very expensive for memory... I found other solutions (some of then unmakable) as use openGL or capture through AVSessions, but no one that can help me...

What are my options ? Any with that problem ?

Thanks for your time !

解决方案

I got it working with protocols.... I'm implementing a protocol in all UIViews classes that make 3D transforms. So when I request a screenshot, it make all subviews screenshot, and generate one UIImage.. Not so good for lots of views, but I'm doing in a few views.

#pragma mark - Protocol implementation 'TDITransitionCustomTransform'

//Conforms to "TDITransitionCustomTransform" protocol, return currrent image view state , by current layer

- (UIImage*)imageForCurrentState {

//Make print

UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0);

[self.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

//return printed image

return screenShot;

}

I was thinking it may works now because I'm doing that render in the transformed view layer, which have being transformed it self... And it wasn't working because "renderInContext:" doesn't get layers of it subviews, may it possible ?

Anyone interest in a bit more code of this solution, can be found here . in the apple dev forum.

It may be a function bug, or it just not being design for this purpose ...

这篇关于" renderInContext:"和CATransform3D的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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