Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing text color of uitabbaritem

Tags:

Is there any way to change the text color of a uitabbar item from default gray to white and the selected color to blue?

like image 409
yogendra Avatar asked Jun 16 '10 09:06

yogendra


People also ask

How do I change the color of my tab bar 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.


1 Answers

Old question, but I have a new answer that is supported in iOS 5 onwards (also I'm using LLVM 4.0 literals)

[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor whiteColor] }                                          forState:UIControlStateNormal]; [[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor blueColor] }                                          forState:UIControlStateSelected]; 
like image 193
bandejapaisa Avatar answered Oct 11 '22 06:10

bandejapaisa