【问题标题】:Stop UIButton fade - Swift停止 UIButton 淡入淡出 - Swift
【发布时间】:2015-06-16 19:19:44
【问题描述】:

是否有办法阻止 UIButton 在其标题更改时执行其淡入淡出动画。

我正在使用一个按钮来显示一个计时器,当按下该按钮时,计时器就会暂停。它工作正常,但每次时间变化时,按钮动画都会启动,它会消失并每秒恢复正常。

【问题讨论】:

    标签: swift button


    【解决方案1】:

    最简单的方法是使用.Custom 按钮而不是.System 按钮。

    【讨论】:

      【解决方案2】:

      这会有所帮助,尽管它似乎并没有完全消除动画:

      CATransaction.begin()
      CATransaction.setDisableActions(true)
      myButton.setTitle(myText, forState: .Normal)
      CATransaction.commit()
      

      【讨论】:

        【解决方案3】:

        如果您正在处理 条形按钮项,您可以通过以下方式阻止动画:

        barButton.title = "New Title Here"
        navigationItem.setLeftBarButton(barButton, animated: false)
        

        【讨论】:

          猜你喜欢
          • 2011-02-17
          • 1970-01-01
          • 1970-01-01
          • 2013-07-16
          • 2011-12-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多