change navigation bar title font - swift

You can do this in Storyboard as well, there is a bug in Xcode 10.1 of doing this here is a trick to overcome this as well.

Step 1 - Choose System from Font

enter image description here

Step 2 - Then again choose Custom and it will show all the fonts.

enter image description here


Try this:

Objective-C

[[UINavigationBar appearance] setTitleTextAttributes:attrsDictionary];

Swift 3

self.navigationController.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: "CaviarDreams", size: 20)!]

Swift 4

self.navigationController.navigationBar.titleTextAttributes = [NSAttributedStringKey.font: UIFont(name: "CaviarDreams", size: 20)!]

Proper way how to set the font for every view controller in Swift (using Appearance proxy):

Swift 5 (and 4.2)

let attributes = [NSAttributedString.Key.font: UIFont(name: "HelveticaNeue-Light", size: 17)!]
UINavigationBar.appearance().titleTextAttributes = attributes

Swift 4

let attributes = [NSAttributedStringKey.font: UIFont(name: "HelveticaNeue-Light", size: 17)!]
UINavigationBar.appearance().titleTextAttributes = attributes

Swift 3

let attributes = [NSFontAttributeName: UIFont(name: "HelveticaNeue-Light", size: 17)!]
UINavigationBar.appearance().titleTextAttributes = attributes