iPhone屏幕快照特定区域 [英] iphone screenshot specific area

查看:46
本文介绍了iPhone屏幕快照特定区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含工具栏和WebView的视图

I have a View including a Toolbar and a WebView

UIVIEW
  UIToolbar
  UIWebview

现在,我只想通过以下方式从WebView截屏:

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

但ImageCapture总是从屏幕的顶部开始.因此它包含了工具栏(状态栏顶部甚至还有20个空白像素)

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)

我如何才能捕获UIWebView中实际显示的图像?

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

感谢克里斯

推荐答案

您的UIWebView由其自己的图层支持,因此您应该能够为其获取当前显示的内容:

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

这篇关于iPhone屏幕快照特定区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆