【发布时间】:2016-08-15 09:52:31
【问题描述】:
在社区的大力帮助下,我制作了按钮图像的放大和缩小动画。问题是,在第一次运行后,该按钮被禁用,并且在重新启动应用程序之前无法再次工作。我想要的是,在单击按钮并完成动画后,它会回到起点,您可以再次单击它。这里有人可以帮我吗?
@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()
}
【问题讨论】:
标签: ios swift xcode uiviewanimation