Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't set font for Navigation Bar in Storyboard of Xcode

Tags:

xcode

ios

fonts

I cannot set font for Navigation Bar in my NavigationController using story board. I checked some questions here. They told options to change the font available in Attributes Inspector. But when I checked there I can't select custom fonts for my NavigationBar. You can see that in below screen shot.

enter image description here

You can see the Font Family field is disabled. So please help me to change the Navigation Bar font from story board. Thanks in advance.

like image 850
Praveen Kumar Avatar asked Dec 03 '22 23:12

Praveen Kumar


2 Answers

You can add custom font with code if you want that font in all project just add it to didFinishLaunchingWithOptions

[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
                                                      [UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName,
                                                      [UIFont fontWithName:@"fontname" size:24.0], NSFontAttributeName, nil]];
like image 28
Mrsantateam Avatar answered Jan 31 '23 13:01

Mrsantateam


Just change Custom to System and change again to Custom. Im not sure why, but this worked for me!

like image 102
J Curti Avatar answered Jan 31 '23 14:01

J Curti