【问题标题】:CALayer renderInContext iOS7CALayer renderInContext iOS7
【发布时间】:2013-09-26 09:45:01
【问题描述】:

我正在渲染多个图层以获得最终图像。其中一张图片包含一张脸,另一张图片包含背景,脸部周围有透明渐变,因此隐藏了真实背景。在 iOS6 中它可以完美运行,但它在 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中的结果:

【问题讨论】:

    标签: ios6 ios7 calayer uigraphicscontext


    【解决方案1】:

    好的,解决方案正在改变这一行:

    UIGraphicsBeginImageContext(rect.size);
    

    对于这个:

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

    现在它也适用于 iOS7

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-04
      相关资源
      最近更新 更多