13

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,

slow_mondays
  • 871
  • 7
  • 19

3 Answers3

19
[[UITabBarItem appearance] setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      [UIColor blackColor], UITextAttributeTextColor, 
      [UIFont fontWithName:@"font" size:0.0], UITextAttributeFont, 
      nil] 
                                             forState:UIControlStateHighlighted];
user1351829
  • 206
  • 1
  • 3
13
[[UITabBarItem appearance] setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      [UIColor blackColor], UITextAttributeTextColor, 
      [UIFont fontWithName:@"ProximaNova-Semibold" size:0.0], UITextAttributeFont, 
      nil] 
                                             forState:UIControlStateHighlighted];


    [[UITabBarItem appearance] setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      [UIColor grayColor], UITextAttributeTextColor, 
      [UIFont fontWithName:@"ProximaNova-Semibold" size:0.0], UITextAttributeFont, 
      nil] 
                                             forState:UIControlStateNormal];
slow_mondays
  • 871
  • 7
  • 19
1

The above answer is working for me.

But I think most people should change the forState:UIControlStateHighlighted to forstate:UIControlStateSelected

Steen
  • 6,573
  • 3
  • 39
  • 56
XcodeNOOB
  • 2,135
  • 4
  • 23
  • 29