<bdo id='f22RV'></bdo><ul id='f22RV'></ul>

  1. <tfoot id='f22RV'></tfoot>

    1. <i id='f22RV'><tr id='f22RV'><dt id='f22RV'><q id='f22RV'><span id='f22RV'><b id='f22RV'><form id='f22RV'><ins id='f22RV'></ins><ul id='f22RV'></ul><sub id='f22RV'></sub></form><legend id='f22RV'></legend><bdo id='f22RV'><pre id='f22RV'><center id='f22RV'></center></pre></bdo></b><th id='f22RV'></th></span></q></dt></tr></i><div id='f22RV'><tfoot id='f22RV'></tfoot><dl id='f22RV'><fieldset id='f22RV'></fieldset></dl></div>

      <small id='f22RV'></small><noframes id='f22RV'>

      <legend id='f22RV'><style id='f22RV'><dir id='f22RV'><q id='f22RV'></q></dir></style></legend>

    2. 如何更改 WKWebView 或 UIWebView 默认字体

      时间:2023-10-22
      <tfoot id='okfaQ'></tfoot>
          <tbody id='okfaQ'></tbody>

          1. <small id='okfaQ'></small><noframes id='okfaQ'>

              <i id='okfaQ'><tr id='okfaQ'><dt id='okfaQ'><q id='okfaQ'><span id='okfaQ'><b id='okfaQ'><form id='okfaQ'><ins id='okfaQ'></ins><ul id='okfaQ'></ul><sub id='okfaQ'></sub></form><legend id='okfaQ'></legend><bdo id='okfaQ'><pre id='okfaQ'><center id='okfaQ'></center></pre></bdo></b><th id='okfaQ'></th></span></q></dt></tr></i><div id='okfaQ'><tfoot id='okfaQ'></tfoot><dl id='okfaQ'><fieldset id='okfaQ'></fieldset></dl></div>

              • <bdo id='okfaQ'></bdo><ul id='okfaQ'></ul>

                <legend id='okfaQ'><style id='okfaQ'><dir id='okfaQ'><q id='okfaQ'></q></dir></style></legend>
              • 本文介绍了如何更改 WKWebView 或 UIWebView 默认字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                UIWebViewWKWebView默认使用什么字体?我希望能够改变这一点.但我不想在 html 字符串中执行此操作,而是希望有类似的内容:

                What font does UIWebView and WKWebView use by default? I would like to be able to change that. But I don't want to do it in the html string, instead I want to have something like:

                // obj-c
                [webView setFont:[UIFont fontWithName:@"GothamRounded-Bold" size:14]
                
                // swift
                webView.setFont(UIFont(name: "GothamRounded-Bold", size: 14))
                

                有没有这样的属性或其他方式?

                is there such property or some other way?

                推荐答案

                您可以使用您的 UIFont 对象(这样您可以更轻松地设置和修改它),但将 HTML 包装在 span 代替;font 标签已被弃用 自 HTML 4.01 起.

                You can use your UIFont object (so you can set it and modify more easily), but wrap the HTML in a span instead; font tags have been deprecated since HTML 4.01.

                UIFont *font = [UIFont fontWithName:@"GothamRounded-Bold" size:14];
                

                假设您已经创建了 NSString *htmlString,您可以使用字体的属性:

                Assuming you already have the NSString *htmlString created, you can use the font's properties:

                htmlString = [NSString stringWithFormat:@"<span style="font-family: %@; font-size: %i">%@</span>",
                                                        font.fontName,
                                                        (int) font.pointSize,
                                                        htmlString];
                

                或者,您可以只提供值而不是使用 UIFont 对象:

                Alternatively, you could just supply the values instead of using a UIFont object:

                htmlString = [NSString stringWithFormat:@"<span style="font-family: %@; font-size: %i">%@</span>",
                                                        @"GothamRounded-Bold",
                                                        14,
                                                        htmlString];
                

                这篇关于如何更改 WKWebView 或 UIWebView 默认字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:UITableViewCell 与 UIWebView 动态高度 下一篇:带有进度条的 UIWebView

                相关文章

                • <bdo id='dzjOf'></bdo><ul id='dzjOf'></ul>
              • <tfoot id='dzjOf'></tfoot>
                  <legend id='dzjOf'><style id='dzjOf'><dir id='dzjOf'><q id='dzjOf'></q></dir></style></legend>

                  <small id='dzjOf'></small><noframes id='dzjOf'>

                  <i id='dzjOf'><tr id='dzjOf'><dt id='dzjOf'><q id='dzjOf'><span id='dzjOf'><b id='dzjOf'><form id='dzjOf'><ins id='dzjOf'></ins><ul id='dzjOf'></ul><sub id='dzjOf'></sub></form><legend id='dzjOf'></legend><bdo id='dzjOf'><pre id='dzjOf'><center id='dzjOf'></center></pre></bdo></b><th id='dzjOf'></th></span></q></dt></tr></i><div id='dzjOf'><tfoot id='dzjOf'></tfoot><dl id='dzjOf'><fieldset id='dzjOf'></fieldset></dl></div>