Reputation: 271
One I decide to make custom navigation bar design the right way. My navigation bar's title should be typed with custom font "Din Condensed" with size 23. So I wrote this code:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navigation_background.png"]
forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleTextAttributes:@{
UITextAttributeTextColor: [UIColor whiteColor],
UITextAttributeFont: [UIFont fontWithName:@"PFDinTextCondPro-Bold" size:23]
}];
But looks like title label can't fit text with this font:
How can I change size of UINavigationBar title using appearance API? I want to avoid using custom titleView.
Upvotes: 1
Views: 6441
Reputation: 189
Set title font in the storyboard.
Now it shouldn't cut your title label.
Upvotes: 0
Reputation: 98
Have you tried setTitlePositionAdjustment
to fix this problem? If this does not work I think the best way is for you to have a UILabel
customized with the font you want and use it as titleView
(custom view) attribute of navigation bar.
Upvotes: 0
Reputation: 4762
There is no way to change its font size. At least not as far as I know. The navigation bar will automatically resize the default title label's font size to fit either in portrait or landscape orientation.
Therefore you need a custom title view. But it's pretty simple; just need to set the navigation item's titleView
to your label.
Example with multiple lines: UINavigationBar multi-line title
Example with single line but different font: https://stackoverflow.com/a/10171426/894671
Good luck!
Upvotes: 4