繁体   English   中英

iPhone屏幕快照特定区域

[英]iphone screenshot specific area

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

UIVIEW
  UIToolbar
  UIWebview

现在我只想使用以下方式从WebView截屏:

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

但总是ImageCapture从屏幕的顶部开始。 因此,它包括工具栏(状态栏顶部甚至20个空白像素)

如何仅捕获UIWebView中的实际图像?

谢谢克里斯

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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