3
在社区的大力帮助下,我制作了放大和缩小按钮图像的动画。问题是,在第一次运行之后,该按钮被禁用,并且在应用重新启动之前不会再工作。我想要的是,单击按钮并且动画完成后,它会返回到起点,然后您可以再次单击它。有人可以帮助我吗?removeAllAnimations()后重置动画
@IBAction func coffeeButton(sender: UIButton) {
var timer = NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector: "stopButtonAnimation", userInfo: nil, repeats: false)
let options = UIViewAnimationOptions.Autoreverse | UIViewAnimationOptions.Repeat | UIViewAnimationOptions.CurveEaseInOut
UIView.animateWithDuration(0.5, delay: 0, options: options, animations: {
self.button.transform = CGAffineTransformMakeScale(0.5, 0.5)
}, completion: nil)
}
func stopButtonAnimation(){
button.layer.removeAllAnimations()
}
谢谢。我希望有一个简单的修复;) –
我很高兴它帮助:) –
关键外卖 - >恢复任何动画到初始状态!在完全不同的环境中为我工作。谢谢。 – inokey