Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting text-color on selected tab bar item

I've created a tab bar application. I have four tabs; on the selected tab, I need to set the color red for tab title. How can i do that?

Thanks in advance.

like image 838
kiran kumar Avatar asked Dec 04 '10 06:12

kiran kumar


People also ask

How do I change the color of my TabBar text?

To change the text color for selected state, inside the TabBar widget, add the labelColor property and set the color. To change the text color for the unselected state, add the unselectedLabelColor parameter and change it colors.


2 Answers

Anyone who's looking for Swift 4 solution..

UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: .red], for: .selected)
like image 83
Gaurav Chandarana Avatar answered Sep 19 '22 17:09

Gaurav Chandarana


This is what finally worked for me:

1)Selected text color

[[UIView appearance] setTintColor:someColor];

2)Unselected text(also changes image color)

[[UITabBar appearance] setTintColor:anotherColor];
like image 43
Rich Fox Avatar answered Sep 21 '22 17:09

Rich Fox