iOS 修改webView字体大小,设置宽度及缩放效果

//设置字体大小
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
    //修改百分比即可
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '40%'"];
}

 

//设置webView内容宽度等于屏幕宽度显示,设置webView的缩放效果
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
    //(initial-scale是初始缩放比,minimum-scale=1.0最小缩放比,maximum-scale=5.0最大缩放比,user-scalable=yes是否支持缩放)
    NSString *meta = [NSString stringWithFormat:@"document.getElementsByName(\"viewport\")[0].content = \"width=self.view.frame.size.width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no\""];
    [webView stringByEvaluatingJavaScriptFromString:meta];
}

 

/**

 

 *  Author:Jn

 *  GitHubhttps://github.com/JnKindle

 *  cnblogshttp://www.cnblogs.com/JnKindle

 */

 

你可能感兴趣的:(iOS,iPhone应用开发,iPad应用开发)