美文网首页iOS技术交流收藏
iOS 如何把view转成image

iOS 如何把view转成image

作者: lucifrom_long | 来源:发表于2015-12-30 17:55 被阅读2102次

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

{

UIGraphicsBeginImageContext(view.bounds.size);

CGContextRef context = UIGraphicsGetCurrentContext();

[view.layer renderInContext:context];

UIImage* tImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return tImage;

}

注意:此方法不是线程安全的。使用时需注意!

相关文章

网友评论

  • 写耶:大神,请问一下这样取到的图片模糊该怎么办~

本文标题:iOS 如何把view转成image

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