Skip to content

Instantly share code, notes, and snippets.

@chourobin
Created December 8, 2013 20:36
Show Gist options
  • Select an option

  • Save chourobin/7863476 to your computer and use it in GitHub Desktop.

Select an option

Save chourobin/7863476 to your computer and use it in GitHub Desktop.
Screenshot of view controller
- (UIImage *)screenshot
{
CGRect rect = CGRectMake(0, 88.0, self.view.frame.size.width, self.view.frame.size.height - 88.0);
UIGraphicsBeginImageContextWithOptions(rect.size, self.view.opaque, 0.0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, -rect.origin.x, -rect.origin.y);
[self.view.layer renderInContext:context];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment