+(UIImage*) imageOfView:(UIView*) view isRetain:(BOOL) retain{
float scale = 1.0;
if (retain == YES) {
scale = 2.0;
}
UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, scale);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
很简单,当我们传入UIWindow的实例时,得到的图片即是我们的程序截图了