2

i want to have white text in navigation bar but i still have it black whenever i have code for white font.

    let titleDict: NSDictionary = [NSForegroundColorAttributeName: UIColor.whiteColor()]
    self.navigationController?.navigationBar.titleTextAttributes = titleDict
    self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "HelveticaNeue-Light", size: 20)]

I tried

self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIColor.whiteColor()]

but didnt worked

Shruti Thombre
  • 989
  • 4
  • 11
  • 27
patrikbelis
  • 1,350
  • 2
  • 16
  • 35

1 Answers1

7

Seems that you are overwriting the changes each time you set titleTextAttributes. Try to set all attributes at the same time:

self.navigationController?.navigationBar.titleTextAttributes = [        
    NSFontAttributeName: UIFont(name: "HelveticaNeue-Light", size: 20),
    NSForegroundColorAttributeName: UIColor.whiteColor()
]
Kirsteins
  • 27,065
  • 8
  • 76
  • 78
  • thanks a lot man! u helped me. I Still have one problem with status bar i choosed in app settings Light Content and used code UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: true) and its still black. – patrikbelis Sep 26 '14 at 12:52
  • At what point in your code (object, method) are you calling this method? – Kirsteins Sep 26 '14 at 13:00
  • i have this code in appdelegate.i just want to have my statusbar white but i still have black. – patrikbelis Sep 26 '14 at 13:18
  • It might be something to do with the fact that navigation bar controls the status bar style. You might find solution here: http://stackoverflow.com/questions/19108513/uistatusbarstyle-preferredstatusbarstyle-does-not-work-on-ios-7 – Kirsteins Sep 26 '14 at 13:30