Hos Ap Hos Ap - 2 months ago 11
Swift Question

change navigation bar title font - swift

I have a title in my navigation bar and a i want to change it to custom font. I've found this line of code, but it's for when you have a navigation controller.

self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "LeagueGothic-Regular", size: 16.0)!,
NSForegroundColorAttributeName: UIColor.whiteColor()]


But i don't have any navigation controller. I added navigation bar manually to my view.

enter image description here

enter image description here

how can i change comment font?

KAR KAR
Answer

Try this,

    UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: fontName]

Hope this will help you.

Comments