Font title does not change in navigation bar

I have a controller built into the navigation controller and I want to change the font of the title in the navigation bar. I want to use a storyboard, so it changes the application (instead of creating a file for the NavigationController and doing this through code); not to the controller: Storyboard

I can change the font size and color, but I cannot change the font family when using the custom font. All other Xcode fonts work in this case. I use my own font everywhere in the application, but it does not work in case of navigation.

What is the cause of this problem?

+5
source share
2 answers

I have exactly the same problem in Xcode 6.4. This may be an Xcode error.

For now, you can install the software font. ( Make sure you have the ttf font file in your project and add the property in the project settings → Information → Fonts provided by the 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]]; 
+11
source

I had the same problem, but it only seemed to me in the storyboard. If you compile your application, it will work fine

0
source

Source: https://habr.com/ru/post/1214691/


All Articles