- 1、UIWebView设置字体大小,颜色,字体:1、UIWebView设置字体大小,颜色,字体:
- UIWebView无法通过自身的属性设置字体的一些属性,只能通过html代码进行设置,代码如下:UIWebView无法通过自身的属性设置字体的一些属性,只能通过html代码进行设置,代码如下:
- 在webView加载完毕后,在
- - (void)webViewDidFinishLoad:(UIWebView *)webView方法中加入js代码
- NSString *str = @"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '60%'";
- [_webView stringByEvaluatingJavaScriptFromString:str];
或加入
From: http://blog.youkuaiyun.com/daiyelang/article/details/23442909
- NSString *jsString = [[NSString alloc] initWithFormat:@"document.body.style.fontSize=%f;document.body.style.color=%@",fontSize,fontColor];
- [webView stringByEvaluatingJavaScriptFromString:jsString];