24

I have created the tabBarController programmatically and I want to change color of tint color of images (not the bar) that tab contains. Can anyone tell me how to do that in Swift?

Marcus Leon
  • 55,199
  • 118
  • 297
  • 429
Rahul Sonvane
  • 3,737
  • 7
  • 18
  • 21

4 Answers4

61

In your 'application:didFinishLaunchingWithOptions'

(window?.rootViewController as! UITabBarController).tabBar.tintColor = UIColor.red

or use appearance delegate.

UITabBar.appearance().tintColor = UIColor.red
Sunil Targe
  • 7,251
  • 5
  • 49
  • 80
Satachito
  • 5,838
  • 36
  • 43
13

Another good solution:

Add Runtime Color attribute named "tintColor".

It will change image tint color as well as title tint color.

enter image description here

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
Sunil Targe
  • 7,251
  • 5
  • 49
  • 80
2

Go to AppDelegate.swift file. In 'application:didFinishLaunchingWithOptions' write:

UITabBar.appearance().unselectedItemTintColor = UIColor.red
0

All above answers are right here I am sharing to achieve this using story board inspector

select your tab bar go to inspector and change image tint to your corresponding colour for reference attaching image

enter image description here

Ahmad Qasim
  • 452
  • 1
  • 8
  • 26