【发布时间】:2013-04-05 14:39:07
【问题描述】:
我有一个相机应用程序可以将照片加载到带面具的设备中。一切都好。当我尝试使用 renderInContext 将视图保存到图像时,我只看到没有任何遮罩的图像。
UIGraphicsBeginImageContext(contentView.bounds.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[contentView.layer renderInContext:context];
UIImage *outImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(outImage, self, @selector(image: didFinishSavingWithError: contextInfo:), context);
我从 Apple 阅读了一些论文说 renderInContext 不支持蒙版和合成。我在互联网上进行了一些搜索,以获取 UIView 需要先绘制为上下文的信息,然后使用 renderInContext 保存图像。
现在我的问题是用什么方法来完成这项工作? drawRect、drawInRect、drawLayer、drawInContent 或其他方法呢?谁能给我一个提示。非常感谢。
【问题讨论】:
标签: ios