Reputation: 184
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]};
Upvotes: 5
Views: 1496
Reputation: 184
i found one solution.. first i create custom label and after that i change font of that....
UIView *iv = [[UIView alloc] initWithFrame:CGRectMake(0,0,230.0,80.0)];
UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 230, 80)];
lbl.textColor = [UIColor whiteColor];
lbl.font = [UIFont fontWithName:@"Ubuntu" size:18.0f];
lbl.textAlignment = NSTextAlignmentCenter;
lbl.text = [NSString stringWithFormat:@"%lu Store Found",(unsigned long)arrOfferList.count];
[iv addSubview:lbl];
self.tabBarController.navigationItem.titleView = iv;
Upvotes: 1
Reputation: 931
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
Upvotes: 1