首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >"renderInContext:“和CATransform3D

"renderInContext:“和CATransform3D
EN

Stack Overflow用户
提问于 2012-03-02 16:36:32
回答 3查看 1.6K关注 0票数 4

我有一个视图,里面有多个视图,还有一个图像演示(也就是。“封面流”)也进入其中...我需要做一个程序截图!

因为文档中说"renderInContext:“不会渲染3d动画:

“重要说明:此方法的Mac v10.5实现不支持整个核心动画合成模型。不会呈现QCCompositionLayer、CAOpenGLLayer和QTMovieLayer层。此外,不会呈现使用3D变换的层,也不会呈现指定backgroundFilters、过滤器、compositingFilter或遮罩值的层。Mac OS X的未来版本可能会添加对呈现这些层和属性的支持。”

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

我已经搜索了很多,我最好的解决方案(那一点都不好)是创建我自己的CGContext,并将所有CG动画录制到其中。但我真的不想这样做,因为我将需要重写我的大部分动画代码,这将是非常昂贵的内存…我找到了其他解决方案(其中一些无法实现),比如使用openGL或通过AVSessions捕获,但没有人可以帮助我……

我有什么选择?有什么问题吗?

感谢您的宝贵时间!

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-03-28 13:58:32

我让它和协议一起工作...我正在所有的UIViews类中实现一个进行3D转换的协议。因此,当我请求截图时,它会生成所有子视图截图,并生成一个UIImage。对于很多视图来说不是很好,但我在一些视图中做了。

代码语言:javascript
复制
#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;

}

我在想它现在可能可以工作了,因为我在转换的视图层中进行渲染,它已经自我转换了……它不能工作是因为"renderInContext:“没有得到它的子视图的层次,这可能吗?

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

它可能是一个函数错误,或者只是不是为这个目的而设计的……

票数 0
EN

Stack Overflow用户

发布于 2012-03-21 18:18:29

你真的试过了吗?我目前正在做一个带有几个3D变换的项目,当我尝试以编程方式制作这个屏幕截图时,它工作得很好:)以下是我使用的代码:

代码语言:javascript
复制
-(UIImage *)getScreenshot
{
    CGFloat scale = 1.0;
    if([[UIScreen mainScreen]respondsToSelector:@selector(scale)])
    {        
        CGFloat tmp = [[UIScreen mainScreen]scale];
        if (tmp > 1.5)
        {
            scale = 2.0;    
        }
    }      
    if(scale > 1.5)
    {
        UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, scale);
    } 
    else
    {
        UIGraphicsBeginImageContext(self.frame.size);
    }    
    //SELF HERE IS A UIVIEW
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];    
    UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return screenshot;
}
票数 0
EN

Stack Overflow用户

发布于 2015-10-29 13:29:05

也许您可以使用Core Graphaic而不是CATransform3DMakeRotation:)

代码语言:javascript
复制
CGAffineTransform flip = CGAffineTransformMakeScale(1.0, -1.0);

哪些内容在renderInContext上生效

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9530250

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档