How to set header font in objective-C

I want to set the font tabBar title as ubuntu, but I can not install it.

I am writing below code for this:

  self.tabBarController.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName:[UIFont fontWithName:@"Ubuntu" size:9.0f]}; 
+5
source share
2 answers

Target Code C -

 [[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 information, fonts and font color iOS5 TabBar

+1
source

I found one solution. First I create a custom label, and after that I change the font of this ....

 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; 
+1
source

All Articles