使用淡入淡出效果更改背景颜色



我想将游戏场景的背景颜色从黑色更改为白色,并具有淡入淡出的效果。我该怎么做?我试过使用动画。

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

这应该有效。我在这里以视图为例,将其替换为您希望使用的任何组件的背景层。

我使用了以下代码:

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

最新更新