Taking a partial screenshot on an iPad

I try to take a screenshot while saving, but I can only take full screen. Is there a way to take a partial screenshot?

Here is an example. Say I just want to take a screenshot in red. Thanks for the help.

http://img197.imageshack.us/img197/6499/sampleimagez.jpg

+5
source share
1 answer

It looks like you need a screenshot of this web view. If you want to get an image of a certain kind and only this kind (+ 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 of this function and it should work.

EDIT:

, , , , Canada Dev. .

+4

All Articles