• <legend id='tGKdH'><style id='tGKdH'><dir id='tGKdH'><q id='tGKdH'></q></dir></style></legend>

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

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

      <tfoot id='tGKdH'></tfoot>
      <i id='tGKdH'><tr id='tGKdH'><dt id='tGKdH'><q id='tGKdH'><span id='tGKdH'><b id='tGKdH'><form id='tGKdH'><ins id='tGKdH'></ins><ul id='tGKdH'></ul><sub id='tGKdH'></sub></form><legend id='tGKdH'></legend><bdo id='tGKdH'><pre id='tGKdH'><center id='tGKdH'></center></pre></bdo></b><th id='tGKdH'></th></span></q></dt></tr></i><div id='tGKdH'><tfoot id='tGKdH'></tfoot><dl id='tGKdH'><fieldset id='tGKdH'></fieldset></dl></div>
      1. UIButton 标签文本被剪裁

        时间:2023-07-30
          <tbody id='NPsfJ'></tbody>

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

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

                  本文介绍了UIButton 标签文本被剪裁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 Interface Builder 中内置了一个具有默认标签的 UIButton.在 Xcode 中,我正在动态更改标签文本,如下所示:

                  I have a UIButton built in Interface Builder that has a default label. In Xcode, I'm changing the label text dynamically like so:

                  myButton.titleLabel.text = @"this is the new label";
                  

                  但是,当文本更新时,新字符串被剪裁到与原始字符串相同的大小,最终看起来像:

                  However, when the text updates, the new string is being clipped down to the same size as the original string and ends up looking like:

                  this...label
                  

                  有人知道为什么会这样吗?

                  Anyone know why this is happening?

                  推荐答案

                  你应该使用 setTitle:forState: 更改 UIButton 的标题.如果您自己更改标题,则按钮不会显示需要调整标签大小 - 您最终将不得不执行以下操作:

                  You should use setTitle:forState: to change the title of a UIButton. If you change the title yourself, the button has no indication that it needs to resize the label –you'd end up having to do something like this:

                  myButton.titleLabel.text = @"this is the new label";
                  [myButton setNeedsLayout];
                  

                  但我什至不确定这是否适用于所有情况.提供了诸如 setTitle:forState: 之类的方法,以便您可以为多个状态提供标题,而无需手动更新按钮,并且按钮知道需要使用新标题对其进行布局.

                  but I'm not even sure that would work in all cases. Methods like setTitle:forState: are provided so that you can provide titles for multiple states without having to update the button manually, and so that the button knows that it needs to be laid out with a new title.

                  这篇关于UIButton 标签文本被剪裁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:奥利奥没有在后台调用 FCM 通知 下一篇:UIButton 在 iOS 5 中不调用操作,但在 iOS 6 中有效

                  相关文章

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

                      <tfoot id='l1kIx'></tfoot>

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

                    1. <legend id='l1kIx'><style id='l1kIx'><dir id='l1kIx'><q id='l1kIx'></q></dir></style></legend>