msalafia
msalafia

Reputation: 2743

Changing Navigation Bar Title Font in Interface Builder

I've implemented a Navigation Controller for my View Controller with storyboard. Now i want changing navigation bar title font and size with Attribute Inspector but it doesn't work and i don't understand why. Title color changes but font dont.

ps: the color changing is visible only at runtime and not in the storyboard.

Attribute Inspector's properties

Upvotes: 23

Views: 17147

Answers (3)

danny
danny

Reputation: 10493

For me Bartłomiej Semańczyk's change to system font & change back trick only works to set the font to a particular system-included font. For custom fonts that I've added, the font face gets set to my custom font but it always gets displayed as size ~16 or so regardless of what size I select in the storyboard.

So the best way I can find to do this is to set self.navigationController.navigationBar.titleTextAttributes in the view controller's viewDidLoad method.

Note that you don't need to do this in every view controller you push onto this navigation stack, just the first one that gets displayed since it sets the property on the navigationBar itself not on the navigationItem. If you're subclassing UINavigationController already, that's the most logical place to set this but I'd rather not subclass it just for this one line change.

Upvotes: 3

Bartłomiej Semańczyk
Bartłomiej Semańczyk

Reputation: 61880

When I tried to set the font, my font field was grayed out. But all I needed to do was change type to System and then again to Custom. It worked:-) Now I can choose my custom font

Upvotes: 29

user821127
user821127

Reputation:

You need to select navigation Bar and then you can set relevant properties. Please check attached image. It might help you.

enter image description here

Upvotes: 30

Related Questions