简体   繁体   中英

iphone screenshot specific area

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

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM