UIWebView字体和背景修改

时间:2021-12-27 07:11:40

 在webView的delegate回调方法-webViewDidFinishLoad:(UIWebView*)webView;中写上以下语句即可

 

//字体大小

    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '110%'"];

//字体颜色

    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= 'gray'"];

//页面背景色

    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.background='#2E2E2E'"];