WKWebView修改网页默认字体的字体,大小,颜色

首页设置代理然后在网页加载完成的时候调用代理方法。

``

//设置代理
self.webView.navigationDelegate = self;

-(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
// 设置字体
NSString *fontFamilyStr = @"document.getElementsByTagName('body')[0].style.fontFamily='Arial';";
[webView evaluateJavaScript:fontFamilyStr completionHandler:nil];
//设置颜色
[ webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= '#9098b8'" completionHandler:nil];
//修改字体大小
[ webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '200%'"completionHandler:nil];
}

``

你可能感兴趣的:(WKWebView修改网页默认字体的字体,大小,颜色)