Author Topic: How do I change the color of the title text in a navigation bar?  (Read 2114 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
Starting in iOS 7, you can use the new titleTextAttributes property of the navigation bar:

In Swift:

Code: [Select]
let titleDict: NSDictionary = [NSForegroundColorAttributeName: UIColor.whiteColor()]
self.navigationController!.navigationBar.titleTextAttributes = titleDict as [NSObject : AnyObject]

In Objective-C:

Code: [Select]
self.navigationController.navigationBar.titleTextAttributes =
        @{NSForegroundColorAttributeName : [UIColor whiteColor]};

All the best!
Kevin McNeish
Author of "Learn to Code in Swift": https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
« Last Edit: July 18, 2015, 03:20:39 PM by kjmcneish »