Greetings and Salutations!

By default in iOS, it changes the UITabBarItem(s) color to gray. You can only change the color of selected item and its background from Interface Builder.
So what you can do is, simply create icons of the color you want to see when items are not selected. Just render icon’s original color through code.
Confused? Let’s understand it with the following example.

I have these two PNG icons.

Now, I’m going to set these icons as TabBarItem images.

These were the results.

 

 

 

 

 

 

 

Let’s create a new Cocoa Touch Class sub class of UITabBarController.


Open your Storyboard and from Interface Builder set the UITabBarController to the Custom TabBar Class you just created.

In viewDidLoad of your Custom TabBar class.

Run.

Add title to the items. Then again in your viewDidLoad of custom class.

After running again.

 

 

 

 

 

 

 

 

 

 

 

Here is the link to the sample project on Github.
So Long!

Share:

administrator

Leave a Reply

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