Ios 如何确定设置UITabBar背景色和色调颜色

Ios 如何确定设置UITabBar背景色和色调颜色,ios,swift,uitabbar,Ios,Swift,Uitabbar,我已经试着设置我的uitabar的色调和背景色很长一段时间了,但似乎没有任何效果。 到目前为止,我已经尝试: tabBarController?.tabBar.backgroundColor = UIColor.orangeColor() tabBarController?.tabBar.barTintColor = UIColor.whiteColor() 以及: UITabBar.appearance().tintColor = UIColor.orangeColor() 这两项似乎都没

我已经试着设置我的
uitabar
的色调和背景色很长一段时间了,但似乎没有任何效果。 到目前为止,我已经尝试:

tabBarController?.tabBar.backgroundColor = UIColor.orangeColor()
tabBarController?.tabBar.barTintColor = UIColor.whiteColor()
以及:

UITabBar.appearance().tintColor = UIColor.orangeColor()

这两项似乎都没有对我的标签栏产生任何影响。我还想提到的是,我将VC嵌入到导航控制器中,我为其设置的全局着色效果非常好。

使用barTintColor设置选项卡栏背景色

self.tabBar.barTintColor = UIColor.blueColor()
//or
UITabBar.appearance().barTintColor = UIColor.blueColor()
对于选项卡栏的着色颜色:

self.tabBar.tintColor = UIColor.whiteColor() // Selected tab color
//or
UITabBar.appearance().tintColor = UIColor.whiteColor()

如果要隐式设置tabbar的
色调和barTint颜色
,请在
Appdelegate.swift

    UITabBar.appearance().barTintColor = .orange
    UITabBar.appearance().tintColor = .green
 self.tabBarController?.tabBar.tintColor = .orange
 self.tabBarController?.tabBar.barTintColor = .green

如果要为特定的viewController设置选项卡栏的
tint和barTint color
,请在
viewController.swift

    UITabBar.appearance().barTintColor = .orange
    UITabBar.appearance().tintColor = .green
 self.tabBarController?.tabBar.tintColor = .orange
 self.tabBarController?.tabBar.barTintColor = .green

Swift 4+版本

UITabBar.appearance().barTintColor = UIColor.red
UITabBar.appearance().tintColor = UIColor.white

我的选项卡栏是这样的,但当用户点击任何选项卡时,该项目将被禁用,但颜色也会改变。我如何更改它?下面是我的问题链接颜色接近但不相同。尝试将视图背景设置为相同的颜色,并亲自查看+1以解释
tintColor
barTintColor
之间的差异。苹果,有没有可能想出更多晦涩难懂、毫无用处的属性名称?嗨@Lion,BartinColor不存在于这个
uitabar.appearance().BartinColor
?@khoung我可以通过访问实例来访问它,但我无法通过
appearance()的类来访问它,只是Xcode完全拒绝在自动完成选项swift 4:uitabar.appearance().barTintColor=UIColor.orange uitabar.appearance().tintColor=UIColor.green
uitabar.appearance()。巴丁特很接近,但绝对不一样。这是预期的吗?这个答案是上面这个答案的副本