如何definitiveley设置UITabBar背景颜色和UITabBar色彩

我一直试图将UITabBar的色彩和背景颜色设置为相当长的一段时间,似乎没有任何效果。 到目前为止,我尝试过:

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

以及:

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

这些似乎都没有对我的标签栏产生任何影响。 我还想提一下,我将VC嵌入到导航控制器中,我设置的全局色调颜色完全正常。

如果要隐式设置tabbar的tint and barTint color ,请在Appdelegate.swift

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

如果要为ViewController.swift特定viewController设置tabbar的tint and barTint color

  self.tabBarController?.tabBar.tintColor = UIColor.orangeColor() self.tabBarController?.tabBar.barTintColor = UIColor.greenColor() 

使用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() 

在此处输入图像描述