【发布时间】:2016-02-06 11:29:11
【问题描述】:
我正在尝试为 animate UIButton 编写一个函数,按顺序执行以下几点:
- 更改按钮文字
- 更改按钮文字颜色
- 使用连续淡入/淡出效果为按钮文本设置动画
所以我写了这个:
static func pulseTitleLabel(button: UIButton, text: String, color: UIColor)
{
button.setTitle(text, forState: [.Normal, .Highlighted])
button.setTitleColor(color, forState: [.Normal, .Highlighted])
UIView.animateWithDuration(1.0, delay: 0.0, options: [.Repeat, .Autoreverse], animations: { () -> Void in
button.titleLabel?.alpha = 0.0
}, completion: nil)
}
但我看不到任何动画。
标题按钮变成了我想要的文本和颜色,但动画没有开始:我错过了什么?还有另一种更好更优雅的方式来做同样的事情吗?
【问题讨论】:
标签: ios swift animation uiview uikit