iPhone屏幕截图特定区域
问题描述:
我有一个观点,包括工具栏和网页视图iPhone屏幕截图特定区域
UIVIEW
UIToolbar
UIWebview
现在我喜欢做的截图只能从与web视图:
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();