I have a controller that is embedded in a Navigation Controller and I want to change the font of the title in the navigation bar. I want to use the storyboard, so it changes across the app (instead of creating a file for NavigationController and doing it via code); not per controller:
I am able to change the font size and color but I am not able to change the font family when using a custom font. All other Xcode fonts work in this case. I use the custom font everywhere in the app but it only doesn't work in case of Navigation.
What can be the reason for this problem?
I have the exactly same problem in Xcode 6.4. This might be a bug of Xcode.
For now, what you can do is to set custom font programmatically. (Make sure you have your font ttf file in your project and add a property in Project Setting -> Info -> Fonts provided by application)
Swift:
self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "LeagueGothic-Regular", size: 16.0)!,
NSForegroundColorAttributeName: UIColor.whiteColor()]
Objective-C:
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], NSForegroundColorAttributeName,
[UIFont fontWithName:@"LeagueGothic-Regular" size:16.0], NSFontAttributeName,nil]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With