Can animate CALayer alpha, but not backgroundColor
I would like to animate the background color of the layer. I can animate the alpha, but I cannot animate the background color.
Works:
var animation = CABasicAnimation(keyPath: "opacity")
animation.toValue = 0.6
animation.duration = 0.1
customCALayer.addAnimation(animation, forKey: nil)
Doesn't work (no animation, no errors):
var animation = CABasicAnimation(keyPath: "backgroundColor")
animation.fromValue = UIColor.redColor().CGColor
animation.toValue = UIColor.whiteColor().CGColor
animation.duration = 0.1
customCALayer.addAnimation(animation, forKey: nil)
What's the deal? backgroundColor
is an animated property .
I have read several posts about this and do not understand what I am missing. The lack of feedback for the noop animation is challenging, I'm not sure where it goes wrong. I have tried casting on AnyObject
using NSValue
as a wrapper and I am not getting anywhere.
Similar answers (which didn't work for me):
+3
source to share
No one has answered this question yet
See similar questions:
or similar: