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

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

    <tfoot id='on2Ei'></tfoot>

      1. 如何从常规 UIFont 创建粗体 UIFont?

        时间:2023-05-31
          <bdo id='bjWbr'></bdo><ul id='bjWbr'></ul>
          <tfoot id='bjWbr'></tfoot>

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

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

                  本文介绍了如何从常规 UIFont 创建粗体 UIFont?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  如果我有一个 UIFont 对象,是否可以将其转换为粗体?我不知道字体名称,我只有一个 UIFont 对象.我想要的是这样的功能

                  If I have a UIFont object, is it possible to convert it to bold? I don't know the font name, I just have a UIFont object. What I want is a function like

                  UIFont *boldFontFromFont(UIFont *input)
                  {
                      return [input derivedFontWithFontWeight:UIFontWeightBold];
                  }
                  

                  如何更改代码以使其正常工作.(上面的代码不起作用,我只是为了说明这一点而编造的.)

                  How can I change the code so that it works. (The code above does not work, I just made it up to illustrate the point.)

                  提前致谢.

                  推荐答案

                  要获得粗体字体,您需要从字体系列中传递特定的字体名称.您可以从给定字体中获取字体系列名称,然后列出该系列中的所有字体.通常,粗体字体的名称中会包含粗体",但格式并不严格,并且可能存在诸如Helvetica-BoldOblique"之类的变体.你可以从这段代码开始:

                  To get a bold font you need to pass a specific name of the font from a font family. You can get a font family name from a given font, then list all fonts from this family. In general, a bold font will contain "bold" in its name, but the format isn't strict and there could be variations like "Helvetica-BoldOblique", for example. You can start from this code:

                  - (UIFont *)boldFontFromFont:(UIFont *)font
                  {
                      NSString *familyName = [font familyName];
                      NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
                      for (NSString *fontName in fontNames)
                      {
                          if ([fontName rangeOfString:@"bold" options:NSCaseInsensitiveSearch].location != NSNotFound)
                          {
                              UIFont *boldFont = [UIFont fontWithName:fontName size:font.pointSize];
                              return boldFont;
                          }
                      }
                      return nil;
                  }
                  

                  这篇关于如何从常规 UIFont 创建粗体 UIFont?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:创建 xmpp muc 房间时遇到问题:代码 503(服务不可用 下一篇:自动引用计数:指向非 const 类型“NSError *"的指

                  相关文章

                  最新文章

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

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

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

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

                      <tfoot id='BoHa7'></tfoot>