Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Font Of tabbar title in objective-C

I want to set font of tabBar title as ubuntu but I can't set that.

I write below code for that:

    self.tabBarController.navigationController.navigationBar.titleTextAttributes = 
      @{NSForegroundColorAttributeName: [UIColor whiteColor], 
      NSFontAttributeName:[UIFont fontWithName:@"Ubuntu" size:9.0f]};
like image 437
Harshit Avatar asked Oct 30 '22 19:10

Harshit


1 Answers

Objective C Code-

[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"your_font_name" size:20.0f], NSFontAttributeName, nil] forState:UIControlStateNormal];

Swift Code-

UITabBarItem.appearance().setTitleTextAttributes(
        [NSFontAttributeName: UIFont(name:"your_font_name", size:11)!, 
            NSForegroundColorAttributeName: UIColor(rgb: 0x929292)], 
        forState: .Normal)

For more refrence- iOS5 TabBar Fonts and Color

like image 87
nilam_mande Avatar answered Nov 09 '22 11:11

nilam_mande