【发布时间】:2017-05-03 15:52:08
【问题描述】:
我正在构建一个计算器应用程序,当我点击按钮时会出现一个简短的动画。问题是按钮在动画时没有响应,这让应用感觉迟钝。
我找到了一些针对 Objective-C 的解决方案:
UIViewAnimationOptionAllowUserInteraction
但 Swift 3 没有,我的代码如下所示:
func myButton () {
sender.layer.backgroundColor = firstColor
sender.setTitleColor(UIColor.white, for: UIControlState.normal)
UIView.animate(withDuration: 0.5) {
sender.layer.backgroundColor = secondColor
}
}
【问题讨论】:
标签: ios swift animation uibutton