UIView转为图片
2019-10-11 本文已影响0人
开发者老岳
//UIGraphicsBeginImageContext(CGSizeMake(view.bounds.size.width, view.bounds.size.height)); //刚方法无scale,所以会模糊
//UIGraphicsBeginImageContextWithOptions(区域大小, 是否是非透明的, 屏幕密度);
UIGraphicsBeginImageContextWithOptions(view.frame.size, YES, UIScreen.mainScreen.scale);
[self.portraitBar.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();