#pragma mark UIView转UIImage
+ (UIImage *)createImageFromView:(UIView *)view
{
CGFloat scale = [UIScreen mainScreen].scale;// 屏幕密度
// 开始绘图,参数1:区域大小;参数2:是否是非透明的(如果需要显示半透明效果,需要传NO,否则传YES);参数3:屏幕密度
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, scale);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();// 生成图片
UIGraphicsEndImageContext();// 关闭绘画通道
return image;
}
UIView转UIImage
最新推荐文章于 2021-09-02 01:02:54 发布