CALayer renderInContext iOS7

编程入门 行业动态 更新时间:2024-10-28 21:15:47
本文介绍了CALayer renderInContext iOS7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在渲染多个图层以获得最终图像。其中一个图像包含一个面,另一个包含一个背景,在面部周围有透明渐变,以便隐藏真实背景。在iOS6中,它完美运行,但它在iOS7中使用透明渐变创建了一种奇怪的效果。

I'm rendering multiple layers to get one final image. One of the images contains a face, and another one contains a background with a transparent gradient around the face so that the real background is hidden. In iOS6 it works perfectly but it is creating a weird effect with the transparent gradient in iOS7.

代码:

CGRect rect = [[UIScreen mainScreen] bounds]; UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); [faceImageView.layer renderInContext:context]; [fakeBackgroundImageView.layer renderInContext:context]; UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

iOS6和iOS7中的结果:

The results in iOS6 and iOS7:

推荐答案

好的,解决方法是改变这一行:

Ok, the solution was changing this line:

UIGraphicsBeginImageContext(rect.size);

这个:

UIGraphicsBeginImageContextWithOptions(rect.size, TRUE, [[UIScreen mainScreen] scale]);

现在它也适用于iOS7

Now it also works in iOS7

更多推荐

CALayer renderInContext iOS7

本文发布于:2023-10-08 03:28:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471386.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:CALayer   renderInContext

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!