0
点赞
收藏
分享

微信扫一扫

iOS 如何把view转成image

Sky飞羽 2021-09-22 阅读 58

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

{

UIGraphicsBeginImageContext(view.bounds.size);

CGContextRef context = UIGraphicsGetCurrentContext();

[view.layer renderInContext:context];

UIImage* tImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return tImage;

}

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

举报

相关推荐

0 条评论