views:

24

answers:

1

Hi,

I have a View including a Toolbar and a WebView

UIVIEW
  UIToolbar
  UIWebview

Now i like to make a screenshot ONLY from the WebView with:

    UIGraphicsBeginImageContext(articleWebView.window.bounds.size);     
    [articleWebView.window.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

But always ImageCapture starts from the TOP of the Screen. So it includes the Toolbar (even 20 empty pixel at the top from the Statusbar)

How can I just capture the Image thats actual in my UIWebView?

Thanks Chris

A: 

Your UIWebView is backed by its own layer, so you should be able to just grab the currently displayed contents for it:

UIGraphicsBeginImageContext(articleWebView.bounds.size);     
[articleWebView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Brad Larson