我目前正在将 html 文件加载到UIWebView
,有时它是表格或 png 图像,我可以保存图像和表格,但它需要的图像在UIWebView
. 查看我的代码:-
UIGraphicsBeginImageContext(theWebView.bounds.size);
// UIGraphicsBeginImageContext(theWebView.frame.size);
[theWebView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
尝试了两种方式,框架和边界。Bounds 给了我完整的图像,但它的模糊和我需要设置内容以适应,UIWebView
以便我可以缩放和滚动UIWebView
。
如果我UIWebView
使用以下代码将内容设置为中心,则由于缩放页面以适应属性,我无法滚动。
NSString *bodyStyle = @"document.getElementsByTagName('body')[0].style.textAlign = 'center';";
[theWebView stringByEvaluatingJavaScriptFromString:bodyStyle];
我如何将页面设置为中心/适当的用户可以滚动并将整个 html 页面保存到相册中的图像。