gpt4 book ai didi

ios - 点击动画延迟手势

转载 作者:搜寻专家 更新时间:2023-11-01 07:27:04 32 4
gpt4 key购买 nike

我有几个从点击手势识别器调用的 UIView 扩展。为什么背景颜色扩展必须先完成动画才能识别其他点击? alpha 扩展加上我用来设置 View 位置动画的另一个扩展工作得很好——这意味着我可以按我想要的速度快速点击,它们会立即响应。

@IBAction func taps(sender: UITapGestureRecognizer) {
if !isAnimating {
currentLabel.fadeOut()
backgroundColor.fadeBackgroundOut()
isAnimating = true
} else {
currentLabel.fadeIn()
backgroundColor.fadeBackgroundIn(curBackground)
isAnimating = false
}
}

func fadeOut() {
UIView.animateWithDuration(0.5,
delay: 0.0,
options: UIViewAnimationOptions.CurveEaseOut,
animations: { self.alpha = 0.0 },
completion: nil)
}

func fadeBackgroundIn(aColor: UIColor) {
UIView.animateWithDuration(1.0,
delay: 0,
options: UIViewAnimationOptions.CurveEaseIn,
animations: { self.backgroundColor = aColor },
completion: nil)
}

最佳答案

将您的扩展更新为:

func fadeOut() {
UIView.animateWithDuration(0.5,
delay: 0.0,
options: [UIViewAnimationOptions.CurveEaseIn , UIViewAnimationOptions.AllowUserInteraction],
animations: { self.alpha = 0.0 },
completion: nil)
}

func fadeBackgroundIn(aColor: UIColor) {
UIView.animateWithDuration(1.0,
delay: 0,
options: [UIViewAnimationOptions.CurveEaseIn , UIViewAnimationOptions.AllowUserInteraction],
animations: { self.backgroundColor = aColor },
completion: nil)
}

关于ios - 点击动画延迟手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35331973/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com