Looking for an example to capture the contents of a UIWebView to a image file, all in the background. Most likely the UIWebView will be hidden or framed off the main window so the user never sees this happening.
Thanks in advance!
Rob
Looking for an example to capture the contents of a UIWebView to a image file, all in the background. Most likely the UIWebView will be hidden or framed off the main window so the user never sees this happening.
Thanks in advance!
Rob
The following code will capture the content of the webview and that will be saved as a .png file
UIGraphicsBeginImageContext(webview.bounds.size);
[webview.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// Write image to PNG
NSString *pngPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.png"];
[UIImagePNGRepresentation(image) writeToFile:pngPath atomically:YES];