在后台捕获UIWebview作为UIImage

时间:2011-08-03 10:03:56

标签: iphone uiwebview uiimage screen capture

我想知道是否有任何技巧可以在后台进行“屏幕捕获”UIWebView?为了澄清更多,我能够使用以下方法捕获UIWebView:

UIGraphicsBeginImageContext(webView.frame.size);
[webView.layer renderInContext: UIGraphicsGetCurrentContext()];
viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
theImageView.image = viewImage;

但我真的必须在屏幕上显示UIWebView才能捕获它,我只是想知道我是否可以在后台执行此操作?

谢谢, 劳伦斯

2 个答案:

答案 0 :(得分:0)

是的,您可以捕获webview。但它只会捕获屏幕的可见部分。

例如,如果您的网络视图高度将超过480(iphone),那么您无法捕获480+的部分。

答案 1 :(得分:0)

SwViewCapture可以将UIWebView的所有内容转换为UIImage。

img