截取View为图片
2019-12-03 本文已影响0人
四季的风
+ (UIImage*)snapshot:(UIView *)shotView {
UIGraphicsBeginImageContext(shotView.frame.size);
UIGraphicsBeginImageContextWithOptions(shotView.frame.size, NO, [[UIScreen mainScreen] scale]);
CGContextRef context = UIGraphicsGetCurrentContext();
[shotView.layer renderInContext:context];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return screenShot;
}