Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the font size of the tab bar controller item name?

I am doing an app based on tabbarController. I have a 3 tabbar items.

My question is: How can I change the font-style for the title on the tab-bar item?

like image 641
Manu Avatar asked Jun 27 '12 07:06

Manu


2 Answers

[self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                            [UIFont fontWithName:@"AmericanTypewriter" size:20.0f], UITextAttributeFont,
                                            [UIColor blackColor], UITextAttributeTextColor,
                                            [UIColor grayColor], UITextAttributeTextShadowColor,
                                            [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)], UITextAttributeTextShadowOffset,
                                            nil]];
like image 178
user1478583 Avatar answered Oct 17 '22 17:10

user1478583


This will change ur UITabBarItem fonts once and for all throughout the app

For Swift use this in AppDelegate's didFinishLaunching:

Swift 3:

UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.blue,NSFontAttributeName: UIFont(name: "Montserrat", size: 11)!], for: .normal)

UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.red,NSFontAttributeName: UIFont(name: "Montserrat", size: 11)!], for: .selected)
like image 41
Ankit Kumar Gupta Avatar answered Oct 17 '22 17:10

Ankit Kumar Gupta