更改带淡入淡出效果的背景颜色

问题描述:

我想将我的GameScene的背景颜色从黑色更改为白色并带有淡化效果。我将如何做到这一点?我试过使用动画。更改带淡入淡出效果的背景颜色

我用这个代码:

self.run(SKAction.colorize(with: UIColor.white, colorBlendFactor: 1, 
duration: 10)) 

UIView.animate(withDuration: 1, animations: { 
     self.viewForBackGroundChange.backgroundColor = UIColor.red 
    }) 

这应该有效。我在这里拿了一个视图的例子,用你希望使用哪个组件的背景层替换它。

+0

这似乎瞬间就变为红色。 UIView.animate(withDuration:10,动画:{ self.backgroundColor = UIColor.red } –

+0

是的,玩的持续时间,这对你有用 –

+0

即使我将持续时间设置为10,000,它仍然会立即改变。 –