项目中需要用当前页面的截屏保存为图片
+ (UIImage *)currentViewScreenPhoto:(UIView *)topView
{
// 高清截屏
UIGraphicsBeginImageContextWithOptions(topView.bounds.size, NO, 0.0);
[topView.layer renderInContext:UIGraphicsGetCurrentContext()];
// 保存为图片
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}
高清
UIGraphicsBeginImageContextWithOptions(topView.bounds.size, NO, 0.0);//原图
模糊
UIGraphicsBeginImageContext(topView.bounds.size);//模糊