【发布时间】:2014-04-11 09:53:53
【问题描述】:
我目前正在将 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 页面保存到相册中的图像。
【问题讨论】:
标签: ios objective-c uiwebview core-graphics uigraphicscontext