+(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的執行個體時,得到的圖檔即是我們的程式截圖了