iOS5 TabBar Fonts and Color

slow_mondays picture slow_mondays · Apr 23, 2012 · Viewed 9.2k times · Source

I have customized the TabBar appearance such

UIImage *tabBackground = [[UIImage imageNamed:@"tab-bar-bg.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UITabBar appearance] setBackgroundImage:tabBackground];
[[UITabBar appearance] setSelectionIndicatorImage: [UIImage imageNamed:@"activetab.png"]];

How do I define the custom fonts and the selected and unselected text colors?

Thanks,

Answer

user1351829 picture user1351829 · Apr 23, 2012
[[UITabBarItem appearance] setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      [UIColor blackColor], UITextAttributeTextColor, 
      [UIFont fontWithName:@"font" size:0.0], UITextAttributeFont, 
      nil] 
                                             forState:UIControlStateHighlighted];