Skip to content

Instantly share code, notes, and snippets.

@nielswh
Created October 30, 2013 18:03
Show Gist options
  • Select an option

  • Save nielswh/7237203 to your computer and use it in GitHub Desktop.

Select an option

Save nielswh/7237203 to your computer and use it in GitHub Desktop.
How to capture specific portion of the screen
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGRect rect = CGRectMake(250,61 ,410, 255);
CGImageRef imageRef = CGImageCreateWithImageInRect([viewImage CGImage], rect);
UIImage *img = [UIImage imageWithCGImage:imageRef];
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
CGImageRelease(imageRef);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment