How to definitively set UITabBar background color and tint color

Harry Merzin picture Harry Merzin · Jun 4, 2016 · Viewed 25.9k times · Source

I have been trying to set my UITabBar's tint color and background color for quite some time now and nothing seems to work. So far I have tried:

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

as well as:

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

Neither of these seemed to have any effect on my tab bar. I'd also like to mention that I have the VC embedded in a navigation controller for which the global tint color that I set works perfectly fine.

Answer

Ketan Parmar picture Ketan Parmar · Jun 4, 2016

If you want to set tabbar's tint and barTint color implicitly then in your Appdelegate.swift,

    UITabBar.appearance().barTintColor = .orange
    UITabBar.appearance().tintColor = .green

If you want to set tabbar's tint and barTint color for specific viewController then in ViewController.swift,

 self.tabBarController?.tabBar.tintColor = .orange
 self.tabBarController?.tabBar.barTintColor = .green