1
所以我将图像掩码一个UIView层与下面的代码中捕捉口罩:无法查看层
CALayer *maskLayer = [CALayer layer];
UIImage *maskImage = self.image.image;
maskLayer.contents = (id)maskImage.CGImage;
maskLayer.frame = CGRectMake(0.0, 0.0,1235, 935);
self.bgView.layer.mask = maskLayer;
一切都很好,很正常,面膜覆盖视图内容和作品。不过,我正在尝试使用屏幕截图让用户保存图像。我使用下面的代码:
UIGraphicsBeginImageContext(captureFrame.size);
[self.bgView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
该框架是好的,它的保存到照片库。唯一的问题是应用于图层的蒙版不会显示在JPG中。我也尝试将我的bgView嵌套到另一个UIView中,然后尝试renderInContext:
,但它是同样的事情。它看起来好像在最后的JPG中没有应用蒙版。
任何想法?谢谢。