Rahul Sonvane
Rahul Sonvane

Reputation: 3907

Swift: Change the image tint color of tab bar?

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?

Upvotes: 24

Views: 22354

Answers (4)

Ahmad Qasim
Ahmad Qasim

Reputation: 474

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

Upvotes: 0

SomethingSolid
SomethingSolid

Reputation: 21

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

UITabBar.appearance().unselectedItemTintColor = UIColor.red

Upvotes: 2

Sunil Targe
Sunil Targe

Reputation: 7459

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

Upvotes: 14

Satachito
Satachito

Reputation: 5888

In your 'application:didFinishLaunchingWithOptions'

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

or use appearance delegate.

UITabBar.appearance().tintColor = UIColor.red

Upvotes: 61

Related Questions