Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 492
Rahul Sonvane Avatar asked May 01 '15 14:05

Rahul Sonvane


People also ask

What is the tint color of a UIView?

tintColor is a variable in UIView that returns a color. The color returned is the first non-default value in the receiver's superview chain (starting with itself). If no non-default value is found, a system-defined color is returned (the shiny blue you always see).


3 Answers

In your 'application:didFinishLaunchingWithOptions'

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

or use appearance delegate.

UITabBar.appearance().tintColor = UIColor.red
like image 171
Satachito Avatar answered Nov 04 '22 02:11

Satachito


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

like image 40
Sunil Targe Avatar answered Nov 04 '22 02:11

Sunil Targe


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

UITabBar.appearance().unselectedItemTintColor = UIColor.red
like image 25
SomethingSolid Avatar answered Nov 04 '22 02:11

SomethingSolid