【问题标题】:How can I animate the UIButton highlight property to extend the time that it stays highlighted?如何为 UIButton 突出显示属性设置动画以延长它保持突出显示的时间?
【发布时间】:2013-12-07 02:59:55
【问题描述】:

尝试以编程方式突出显示配置为“Shows Touches On Highlight”的 UIButton,发现以下代码无法正确设置动画(持续时间无效;突出显示只是闪烁):

button.highlighted = YES;
[UIView animateWithDuration:3.0
                 animations:^{ button.highlighted = NO; }
 ];

也尝试过,结果相似(只是一闪而过):

button.highlighted = YES;
[UIView animateWithDuration:3.0
                 animations:^{}
                 completion:^(BOOL finish){ button.highlighted = NO; }
 ];

以编程方式打开按钮突出显示并在一段时间后将其关闭的最佳方法是什么?

【问题讨论】:

    标签: animation uibutton highlight


    【解决方案1】:

    以下代码产生了预期的结果:

    button.highlighted = YES;
    [self performBlock:^{ button.highlighted = NO; } afterDelay:3.0];
    

    注意:3.0 秒仅用于说明/一致性; 0.3 秒其实就是我们想要的视觉效果。

    【讨论】:

      猜你喜欢
      • 2012-05-29
      • 2014-09-10
      • 1970-01-01
      • 1970-01-01
      • 2015-08-01
      • 2014-02-03
      • 1970-01-01
      • 1970-01-01
      • 2012-04-22
      相关资源
      最近更新 更多