I'm trying to take a screenshot on save, but can only do full screen. Is there any way to take a partial screenshot?
Here is a sample. Say I just want to take a screenshot of the section highlighted in red. Thanks for the help.
http://img197.imageshack.us/img197/6499/sampleimagez.jpg
It looks like you want a screenshot of that web view there. If you want to get an image of a specific view and only that view (+ subviews), you can use the following code:
- (UIImage*)captureView:(UIView*)view
{
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale);
else
UIGraphicsBeginImageContext(self.view.bounds.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[view.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
Just pass the web view to that function and it should work.
EDIT:
Assuming that was just an example image and you want a screenshot of an area that is not contained in its own view, go with Canada Dev's solution. Crop the image to the area that you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With