Xcode 我们可以在CABasicAnimation中指定UIColor值吗?

Xcode 我们可以在CABasicAnimation中指定UIColor值吗?,xcode,swift,uicolor,cabasicanimation,scnnode,Xcode,Swift,Uicolor,Cabasicanimation,Scnnode,我想为3D球添加发光动画 let ball = SCNNode(geometry: SCNSphere(radius: 20)) let highlightAnimation = CABasicAnimation(keyPath: "contents") highlightAnimation.toValue = UIColor.yellowColor() highlightAnimation.fromValue = UIColor(hue: 0.01, saturation: 1,

我想为3D球添加发光动画

let ball = SCNNode(geometry: SCNSphere(radius: 20))

let highlightAnimation = CABasicAnimation(keyPath: "contents")
highlightAnimation.toValue = UIColor.yellowColor()
highlightAnimation.fromValue = UIColor(hue: 0.01, saturation: 1,
                               brightness: 0.6, alpha: 1) //supposed to be dark red
//other unimportant codes for initialization

ball.geometry!.firstMaterial!.emission.addAnimation(highlightAnimation, forKey: nil)
结果是,当我运行程序时,颜色从鲜红色(相当于
UIColor.redColor
)变为亮黄色,而不是我想要的颜色。显然,该属性只接受默认
UIColor
属性中的颜色。有没有办法定制颜色


非常感谢

使用“backgroundColor”关键路径设置颜色动画。在添加动画之前,您是否尝试过将材质的颜色设置为起始暗红色?@generatorOfOne它不起作用。编译器将抛出此选项:[SCNKit ERROR]backgroundColor不是可设置动画的路径。顺便问一下,你能解释一下什么是keypath吗?我好像找不到它online@GaryMakin是的,我已经设置好了。事实上,我通过使用自定义几何体函数设置几何体,在该函数中,我将漫反射特性设置为特定颜色