ksealey ksealey - 1 year ago 161
Swift Question

Setting UINavigationController Bar title in Swift 2.0

I am trying to set my navigation bar title but no matter where I set the title it will not show. I have the background color set and that change is applied, just not the title. Please advise.

import UIKit

class CustomNavigationController: UINavigationController{
override func viewDidLoad() {
navigationBar.tintColor = UIColor.themeDarkGray()
navigationBar.barTintColor = UIColor.themeDarkGray()
navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()] // Title's text color
self.title = "Title Here"


Answer Source

Try this:

self.navigationController?.navigationBar.topItem?.title = "Title here".

It should work! :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download