2010-07-26 82 views
1

我有一個觀點,包括工具欄和網頁視圖iPhone屏幕截圖特定區域

UIVIEW 
    UIToolbar 
    UIWebview 

現在我喜歡做的截圖只能從與web視圖:

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

但始終ImageCapture中從開始屏幕的頂部。 因此,它包括工具欄(即使在狀態欄頂部的20個空像素)

我怎樣才能捕獲在我的UIWebView實際的圖像呢?

感謝克里斯

回答

1

你的UIWebView通過其自身的層支持,所以你應該能夠只是抓住當前顯示的內容吧:

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