- 1. UIWebView set font size, color, font: 1. UIWebView set font size, color, font:
- UIWebView cannot set some properties of fonts through its own properties, but can only set them through html codes. The code is as follows: UIWebView cannot set some properties of fonts through its own properties, but can only set them through html codes. The codes are as follows:
- After the webView is loaded, in
- - ( void )webViewDidFinishLoad: ( UIWebView *) add js code to the webView method
- NSString *str = @"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '60%'";
- [_webView stringByEvaluatingJavaScriptFromString:str];
or join
From: http://blog.csdn.net/daiyelang/article/details/23442909
- NSString *jsString = [[NSString alloc] initWithFormat:@"document.body.style.fontSize=%f;document.body.style.color=%@",fontSize,fontColor];
- [webView stringByEvaluatingJavaScriptFromString:jsString];