0
我正在使用动画在两种颜色之间淡化按钮,并且在按下按钮时需要获取其当前颜色。在Swift中的动画中获取UIView的颜色?
这里的动画代码:
UIView.animateWithDuration(speed, delay: 0.0, options:[UIViewAnimationOptions.Repeat, UIViewAnimationOptions.Autoreverse, UIViewAnimationOptions.AllowUserInteraction, UIViewAnimationOptions.CurveEaseOut], animations: {
targetView.layer.backgroundColor = self.randomColors(40).CGColor
targetView.layer.backgroundColor = self.randomColors(250).CGColor
}, completion: nil)
阅读使用targetView.layer.backgroundColor
颜色每次,不是颜色在那个特定的时刻给了我同样的结果。我已经尝试了几个函数来获得屏幕上特定像素的颜色,但它们只是每次都返回相同的颜色。
按下按钮后不需要继续动画,我只需要在按下按钮时获取颜色。
任何帮助将是惊人的,谢谢!
谢谢!那正是我所追求的。非常感激。 – Stephen
@Stephen高兴地帮助:) – Hamish