我有使用tabBar的iOS应用程序,我想要更改tabBar背景颜色。我是这样做的:
@IBAction func lightTheme(_ sender: UIButton) {
GlobalSettings.sharedManager.isDarkMode = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1){
Theme.defaultTheme()
self.loadView()
}
}
然后:
func updateDisplay() {
let proxyTabBar = UITabBar.appearance()
proxyTabBar.tintColor = UIColor(displayP3Red: 215/255, green: 91/255, blue: 33/255, alpha: 1
proxyTabBar.backgroundColor = TAB_BAR_BACKGROUND
proxyTabBar.barTintColor = TAB_BAR_BACKGROUND
proxyTabBar.unselectedItemTintColor = .gray
}
但只有在没有此tabBar的情况下打开新视图后,tabBar的颜色才会更改。