美文网首页
UIView 转 UIImage

UIView 转 UIImage

作者: 坤哥爱卿 | 来源:发表于2017-07-11 11:32 被阅读14次

- (UIImage*) imageWithUIView:(UIView*) view{

//创建一个bitmap的context

//并把它设置成为当前正在使用的context

UIGraphicsBeginImageContext(CGSizeMake(view.bounds.size.width, view.bounds.size.height));

CGContextRefcurrnetContext =UIGraphicsGetCurrentContext();

[view.layerrenderInContext:currnetContext];

//从当前context中创建一个改变大小后的图片

UIImage* image =UIGraphicsGetImageFromCurrentImageContext();

//使当前的context出堆栈

UIGraphicsEndImageContext();

returnimage;

}

相关文章

网友评论

      本文标题:UIView 转 UIImage

      本文链接:https://www.haomeiwen.com/subject/vvqssttx.html