Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change tabbar text color,iPhone

Tags:

ios

uitabbar

I have created a tabbar programmatically.

Can we change color of title of the tabbar item? Default is white, and i m trying to make it black.

something like

 tabbaritem.text.textcolor=[UIcolor Blackcolor];

Thanks

like image 838
FirstTimer Avatar asked Nov 28 '22 04:11

FirstTimer


1 Answers

In iOS5 you use the appearance proxy to change the title color:

For a specific tabbar item:

[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                         [UIFont fontWithName:@"AmericanTypewriter" size:20.0f], UITextAttributeFont,
                                         [UIColor yellowColor], UITextAttributeTextColor,
                                         [UIColor redColor], UITextAttributeTextShadowColor,
                                         [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)], UITextAttributeTextShadowOffset,
                                         nil] forState:UIControlStateNormal];

Or replace self.tabBarItem with [UITabBarItem appearance] to change all your tabbar items. If you want to change them all , I suggest you place the code on appdelegate didFinishLaunchingWithOptions:

like image 71
rckoenes Avatar answered Dec 09 '22 14:12

rckoenes