Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tab bar item tint color

In iOS 7, I been developing an app that uses the UITabBarController and I noticed that the tab bar items stay gray even tho I change the tint color of the tab bar. Is there any way to change the color of non-selected tab bar items?

like image 432
Reza Safari Avatar asked Jan 26 '14 07:01

Reza Safari


People also ask

How do I change the color of a tab bar in Swift?

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

What is tab bar controller in Swift?

What's A Tab Bar Controller? A tab bar controller, of class UITabBarController, is a container view controller. It typically organizes 3-5 view controllers in a group. The user of your app can switch between view controllers by tapping one of the tabs in the tab bar at the bottom of the screen.


2 Answers

To do this:: follow a simple approach..

  1. Change tintColor as you want

  2. Add a new set of images for unselected items and render them in original mode.

For more info, read through this link

like image 136
Balram Tiwari Avatar answered Oct 05 '22 23:10

Balram Tiwari


To sets the tint color globally for the app, you need to add below code In app delegate didFinishLaunchingWithOptions: method:

[[UITabBar appearance] setTintColor:[UIColor colorWithRed:13.0/255.0 green:116.0/255.0 blue:128.0/255.0 alpha:1.0]];
like image 32
Iya Avatar answered Oct 06 '22 00:10

Iya