簡體   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