Here is how to programatically change UITabBar Tint Color, UITabBar Item Tint Color & also how to change UITabBar Item’s unselected icon tint color.

Assumption: I assume you have deployed UITabBarViewController in your iOS App. And now you want to change UITabBar Tint color, UITabBar Item’s Tint color and also UITabBar’s unselected icon’s tint color.

 
Do this is just simple as single line of code.

 
Below code will go to your Apple iOS app’s AppDelegate.swift file under ‘didFinishLaunchingWithOptions’ function.

 
So your code will look something like this.

 

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UITabBar.appearance().tintColor = UIColor(red: 0/255, green: 0/255, blue: 255/255, alpha: 1.0)
UITabBar.appearance().barTintColor = UIColor(red: 0/255, green: 0/255, blue: 0/255, alpha: 1.0)
UITabBar.appearance().unselectedItemTintColor = UIColor(red: 0/255, green: 255/255, blue: 0/255, alpha: 1.0)
}

 
Hope it helps,

 
Thanks & Regards
Mandar Apte

Leave a Reply

Your email address will not be published. Required fields are marked *