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

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

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

        iOS:在 UIBarButtonItem 和 Button 中附加带有标题的 FontAwesome 图标

        时间:2023-07-08
          <bdo id='JcKoS'></bdo><ul id='JcKoS'></ul>
            1. <tfoot id='JcKoS'></tfoot>

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

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

                  本文介绍了iOS:在 UIBarButtonItem 和 Button 中附加带有标题的 FontAwesome 图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想要在我的 NavigationBar 中使用这样的 UIBarButton 项,并且

                  I want a UIBarButton Item like this in my NavigationBar and

                  像这样的普通 UIButton

                  Normal UIButton like this

                  我已经尝试过使用这些链接问题1 问题 2 问题 3 但没有得到输出.

                  I already tried using these links Question 1 Question 2 Question 3 but didn't got the output.

                  我需要将那个 FontAwesome 图标附加到按钮标题文本中.

                  My need is to append that FontAwesome icon with the button title text.

                  有人可以帮忙吗?

                  我的代码是:

                  NSString *icon = [NSString fontAwesomeIconStringForIconIdentifier:@"fa-folder-open"];
                  
                  NSString *locationString = [NSString stringWithFormat:@"%@ %@", icon, @"Change"];
                  
                  NSMutableAttributedString *astring = [[NSMutableAttributedString alloc] initWithString:locationString];
                  
                  [astring addAttribute:NSFontAttributeName
                                  value:[UIFont iconicFontOfSize:20]
                                  range:NSMakeRange(0,1)]; // The first character
                  
                  changeFolderButton.titleLabel.attributedText = astring;
                  

                  推荐答案

                  如果FontAwesome图标的code是"&#xf007",则设置text为@"U0000f007" 改成标题.

                  If code of FontAwesome Icon is "&#xf007", then set text to @"U0000f007" into Title.

                  UIButton 使用以下代码:-

                  myBtn.titleLabel.font =[UIFont fontWithName:@"FontAwesome" size:20.0];
                  [myBtn setTitle:@"U0000f007" forState:UIControlStateNormal]];
                  

                  UIBarButton 使用以下代码:-

                  [self.barButton setTitleTextAttributes:@{
                                NSFontAttributeName: [UIFont fontWithName:@"FontAwesome" size:24.0],
                                NSForegroundColorAttributeName: self.view.tintColor
                                                       } forState:UIControlStateNormal]; 
                  [self.barButton setTitle:@"U0000f007"]];
                  

                  如果您想在字符串中附加图标,请使用以下代码:-

                  If you want to append your string with icon then use following code:-

                  NSString * myString = @"U0000f007 Change";
                  NSMutableAttributedString *astring = [[NSMutableAttributedString alloc] initWithString:myString];
                  [astring addAttribute:NSFontAttributeName
                                  value:[UIFont fontWithName:@"FontAwesome" size:22.0]
                                  range:NSMakeRange(0,1)]; //If Icon is on starting position
                  [myBtn setAttributedTitle:astring forState:UIControlStateNormal];
                  

                  希望,这就是您要找的.任何问题都可以回复我.:)

                  Hope, this is what you're looking for. Any concern get back to me. :)

                  这篇关于iOS:在 UIBarButtonItem 和 Button 中附加带有标题的 FontAwesome 图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为 UIButton 添加目标 - iOS 下一篇:UIButtons之间的自动布局相等空间

                  相关文章

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

                    <tfoot id='75i3i'></tfoot>

                      <small id='75i3i'></small><noframes id='75i3i'>

                        <bdo id='75i3i'></bdo><ul id='75i3i'></ul>