Skip to content

Instantly share code, notes, and snippets.

@justinHowlett
Created June 20, 2013 23:40
Show Gist options
  • Save justinHowlett/5827739 to your computer and use it in GitHub Desktop.
Save justinHowlett/5827739 to your computer and use it in GitHub Desktop.
UIView Category for producing a raster copy
#include <QuartzCore/QuartzCore.h>
@implementation UIView (Raster)
-(UIImage*)getRasterCopy{
/* returns UIImage of any UIView */
UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, 0.0);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultingImage;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment