【发布时间】:2016-04-08 17:36:05
【问题描述】:
我正在使用动画在两种颜色之间淡化按钮,并且需要在按下按钮时获取其当前颜色。
这是动画代码:
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 读取颜色每次都会给我相同的结果,而不是特定时刻的颜色。我尝试了一些函数来获取屏幕上特定像素的颜色也无济于事,它们每次都返回相同的颜色。
按下按钮后动画不需要继续,我只需要获取按下按钮时的颜色即可。
任何帮助都会很棒,谢谢!
【问题讨论】:
标签: ios swift animation colors