1.遵守UIWebViewDelegate代理
2.实现方法
-(void)webViewDidFinishLoad:(UIWebView *)webview
{
[_refWebView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName(‘body‘)[0].style.webkitTextSizeAdjust= ‘50%‘"];//修改字体大小, 修改百分比即可
NSString *scale = [NSString stringWithFormat:@"document.getElementsByName(\"viewport\")[0].content = \"width=self.view.frame.size.width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=5.0, user-scalable=yes\""];
[_refWebView stringByEvaluatingJavaScriptFromString:scale];//修改宽度及缩放效果, (initial-scale是初始缩放比,minimum-scale=0.5最小缩放比,maximum-scale=5.0最大缩放比,user-scalable=yes是否支持缩放)
}
时间: 2024-11-13 09:05:46