ksealey
ksealey

Reputation: 1738

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() {
          super.viewDidLoad()
          navigationBar.tintColor = UIColor.themeDarkGray()
          navigationBar.barTintColor = UIColor.themeDarkGray()
          navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()]  // Title's text color
          self.title = "Title Here"

      }
  }

Upvotes: 2

Views: 4034

Answers (2)

Maty Brennan
Maty Brennan

Reputation: 51

if you set custom NavBar then:

Self.navigationBar.pushItem(UINavigationItem(title: "Title"), animated: true)

Upvotes: 2

Mtoklitz113
Mtoklitz113

Reputation: 3878

Try this:

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

It should work! :)

Upvotes: 12

Related Questions