开发者

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 = UIGraphic开发者_运维知识库sGetImageFromCurrentImageContext();
    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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜