#pragma mark -
#pragma mark Capture
- (UIImage *)capture
{
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.view.layerrenderInContext:UIGraphicsGetCurrentContext()];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}

本文介绍了一种将UIView渲染为UIImage的方法。通过使用UIGraphicsBeginImageContextWithOptions开始图像上下文,并利用self.view.layer.renderInContext将UIView的内容绘制到当前图像上下文中,最终获取到UIImage对象。
1382

被折叠的 条评论
为什么被折叠?



