Tag: 生气和执着

连续animation调用不起作用

我有一个button,调用animateWithDuration代码淡出图像,淡入淡出的文本和新的颜色,然后重置为正常。 animation需要几秒钟才能完成,效果很好。 然而! 有一个问题: 有时候这个button会在animation结束之前再次被按下。 发生这种情况时,我希望当前animation停止并重新开始。 研究解决scheme不工作 根据我的阅读,解决scheme应该是简单的,只需导入QuartzCore并添加: button.layer.removeAllAnimations() 这确实删除了animation,但新的/第二个animation是完全搞砸了。 应该隐藏的图像不是,文本从不出现,颜色转换全部错误。 发生了什么!?! //Animate Finished feedback in footer bar func animateFinished(textToDisplay: String, footerBtn: UIButton, footerImg: UIImageView) { //Should cancel any current animation footerBtn.layer.removeAllAnimations() footerBtn.alpha = 0 footerBtn.setTitle(textToDisplay, forState: UIControlState.Normal) footerBtn.titleLabel!.font = UIFont(name: "HelveticaNeue-Regular", size: 18) footerBtn.setTitleColor(UIColor(red: 255/255.0, green: 255/255.0, blue: 255/255.0, alpha: 1.0), forState: UIControlState.Normal) footerBtn.backgroundColor […]