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

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

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

      1. UILabel 在 UIView 内没有动画,使用了自动布局

        时间:2023-09-10

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

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

            • <small id='ANlyL'></small><noframes id='ANlyL'>

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

                • 本文介绍了UILabel 在 UIView 内没有动画,使用了自动布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个非常简单的应用程序.它包含一个红色视图和一个绿色标签.还有一个运行动画的按钮.我通过更改其宽度约束常量的值来为红色视图设置动画.

                  I have a very simple application. It contains a red view and a green label inside it. There is also a button that runs animation. I animate the red view by changing its width constraint constant's value.

                  [self.view layoutIfNeeded];
                  [UIView animateWithDuration:0.4 animations:^{
                      self.widthConstraint.constant = width;
                      [self.view layoutIfNeeded];
                  }];
                  

                  红色视图按预期进行动画处理,但内部的绿色标签会立即改变其宽度.我玩了不同的动画标志,尝试了 SO 的几个技巧,但没有成功.

                  The red view animates as expected, but the green label inside changes its width instantly. I played with different animation flags, tried several tips from SO but did not bring it work.

                  请在此处找到来源.

                  TIA

                  推荐答案

                  看来我找到了问题的根源.约束不是问题,UILabel 是.

                  It seems like I've found the root of the problem. Constraints are not a trouble, UILabel is.

                  如果您将我的项目中的 UILabel 替换为简单的 UIView,它将按预期流畅地制作动画.这是 UILabel 内容动画的问题.您可以达到正确的动画行为集 label.contentMode = UIViewContentModeCenter 但它看起来很丑.

                  If you replace UILabel in my project with simple UIView it will animate smoothly as expected. It's a question of UILabel content animation. You can reach correct animation behaviour set label.contentMode = UIViewContentModeCenter but it looks ugly.

                  解决此问题的最佳方法 - 不要在动画期间尝试更改 UILabel 的大小.尝试发明一些其他行为.在我的情况下,我将 UILabel 的 alpha 更改为 0,并将 x 位置更改为大于容器视图的宽度.

                  The best way to solve this problem - not try to change size of UILabel during animation. Try to invent some other behaviour. In my case I change UILabel's alpha to 0 and x position to greater then container view's width.

                  请在这里找到更多关于 UILabel 动画的详细信息一个>.

                  Please find more details about UILabel animating here.

                  这篇关于UILabel 在 UIView 内没有动画,使用了自动布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:向 UIBarButtonItem 添加约束 下一篇:在 Swift 中将字体大小更改为 25 时标签消失

                  相关文章

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

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

                    <tfoot id='ey3B3'></tfoot>