Skip to content

Instantly share code, notes, and snippets.

@adow
Created December 10, 2013 15:49
Show Gist options
  • Save adow/7892831 to your computer and use it in GitHub Desktop.
Save adow/7892831 to your computer and use it in GitHub Desktop.
Make an image for UIView
///为UIView创建一个截图
static inline UIImage* WKFlip_make_image_for_view(UIView* view){
double startTime=CFAbsoluteTimeGetCurrent();
if(UIGraphicsBeginImageContextWithOptions != NULL){
UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, 0.0);
} else {
UIGraphicsBeginImageContext(view.frame.size);
}
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage* image=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSLog(@"makeImage duration:%f", CFAbsoluteTimeGetCurrent()-startTime);
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment