Skip to content

Instantly share code, notes, and snippets.

@Nub
Created October 5, 2011 03:01
Show Gist options
  • Select an option

  • Save Nub/1263517 to your computer and use it in GitHub Desktop.

Select an option

Save Nub/1263517 to your computer and use it in GitHub Desktop.
+ (UIImage *)screenShot:(UIView *)aView inRect:(CGRect)aRect
{
// Arbitrarily masks to 40%. Use whatever level you like
UIGraphicsBeginImageContext(aRect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, 0, -aRect.origin.y);
[aView.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
CGContextSetRGBFillColor (context, 0, 0, 0, 0.4f);
CGContextFillRect (context, aRect);
UIGraphicsEndImageContext();
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment