UIButtons are not responding during animation - iOS Swift 3

前端 未结 1 1290
[愿得一人]
[愿得一人] 2021-01-16 15:46

I\'m building a calculator app, when I tap on the buttons there is a short animation. The problem is the buttons do not respond while they are animating, which makes the app

相关标签:
1条回答
  • 2021-01-16 15:56

    Call different method of UIView:

    func myButton () {
        sender.layer.backgroundColor = firstColor
        sender.setTitleColor(UIColor.white, for: UIControlState.normal)
    
        UIView.animate(withDuration: 0.5,
                       delay: 0.0,
                       options: .allowUserInteraction,
                       animations: {
                           sender.layer.backgroundColor = secondColor },  
                       completion: nil)
    }
    
    0 讨论(0)
提交回复
热议问题