当我使用重复和自动反转选项为按钮设置动画时,@IBAction
无效。
动画代码:
UIView.animateWithDuration(0.5, delay: 0.4, options: [.Repeat, .Autoreverse], animations: {
self.Button.frame = CGRect(x: 80, y: 80, width: 50, height: 50)
}, completion: nil)
行动代码:
@IBAction func BtnAction(sender: UIButton) {
Label.text = "Button pressed"
}
答案 0 :(得分:0)
如@Shripada所述,我必须在选项参数中添加.allowUserInteraction
UIView.animateWithDuration(0.5, delay: 0.4, options: [.repeat, .autoreverse, .allowUserInteraction], animations: {
self.button.frame = CGRect(x: 80, y: 80, width: 50, height: 50)
}, completion: nil)