欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

iOS WKWebView加载HTML字体大小问题

程序员文章站 2022-03-27 21:37:12
NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);"; WKUserScript *wkUScript = [......

NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);";

    

    WKUserScript *wkUScript = [[WKUserScript alloc] initWithSource:jScript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];

    WKUserContentController *wkUController = [[WKUserContentController alloc] init];

    [wkUController addUserScript:wkUScript];

    

    WKWebViewConfiguration *wkWebConfig = [[WKWebViewConfiguration alloc] init];

    wkWebConfig.userContentController = wkUController;

    

    // 创建设置对象

    WKPreferences *preference = [[WKPreferences alloc]init];

    // 设置字体大小(最小的字体大小)

    preference.minimumFontSize = 15;

    // 设置偏好设置对象

    wkWebConfig.preferences = preference;

    WKWebView *webView = [[WKWebVi

本文地址:https://blog.csdn.net/ANDY_GUO_wei/article/details/107489382