我正在尝试使用 appDeligate 文件更改状态栏和 UINavigationBar 的背景颜色,但不知何故更改的颜色不会显示为纯色,它从一开始就以一些渐变的形式出现,请参阅下图 这是我在 AppDelegate 中声明的 didFinishLaunchingWithOptions 函数
UINavigationBar.appearance().backgroundColor = UIColor(red: 159/255, green: 31/255, blue: 99/255, alpha: 100)
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
最佳答案
谢谢大家,在寻找更改标签栏颜色的答案后,我早些时候找到了这个问题的答案,我的 AppDelegate 是。
UINavigationBar.appearance().backgroundColor = UIColor(red: 159/255, green: 31/255, blue: 99/255, alpha: 100)
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
现在我将其更改为
UINavigationBar.appearance().barTintColor = UIColor(red: 159/255, green: 31/255, blue: 99/255, alpha: 100)
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
我的问题解决了
关于ios - UINavigationBar 背景颜色不显示为纯色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54604242/