Take an image of the invisible part of the UIWebView

I want to create uiimage s from parts of some uiwebview content.

Suppose my webview has a size of (200,200). And it has content (800,200) in its content, which scrolls,

I want to take a screenshot of the next rectangle CGRectMake (400,0,200,200).

I tried this:

CGRect rect = CGRectMake(pageIndex * webView.frame.size.width, 0, webView.frame.size.width, webView.frame.size.height); UIGraphicsBeginImageContext([webView getScrollView].bounds.size); CGContextRef c = UIGraphicsGetCurrentContext(); CGContextClipToRect(c, rect); [webView.layer renderInContext:c]; UIGraphicsEndImageContext(); 

It works for the first page of webview, but for other pages it does not accept the image created by the white image.

What could be the problem? How to create screenshots of invisible scroll parts?

Thanks for the help,

+4
source share

All Articles