UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName doesn't work

uinavigationbar background color
uinavigationbar title color
uinavigationbar text color
change navigation bar color swift
uinavigationbar font
navigation bar title font swift

I am trying to set the title color in my UINavigationBar in my AppDelegate.swift, like this-

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    UINavigationBar.appearance().barTintColor = UIColor(red: 26.0/255.0, green: 188.0/255.0, blue: 156.0/255.0, alpha: 1.0)
    UINavigationBar.appearance().tintColor = UIColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1.0)
    UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
    UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: UIFont(name: "Pacifico", size: 24)!]

    // Turquoise color rgba(26, 188, 156,1.0)

    return true

But it doesn't work. The result looks like Why isn't this working? Thanks!

You're overwriting the titleTextAttributes value you set initially with the color to a new value that includes only the font.

You should combine your attributes and then set them at once:

Edit: Swift 4

let color = UIColor.white
let font = UIFont(name: "Pacifico", size: 24)!

let attributes: [NSAttributedStringKey: AnyObject] = [
        NSAttributedStringKey.font: font,
        NSAttributedStringKey.foregroundColor: color

UINavigationBar.appearance().titleTextAttributes = attributes

Swift 3

let color = UIColor.white
let font = UIFont(name: "Pacifico", size: 24)!

let attributes: [String: AnyObject] = [
    NSFontAttributeName: font,
    NSForegroundColorAttributeName: color

UINavigationBar.appearance().titleTextAttributes = attributes

Customize navigation bar appearance with swift (Example), fixed it for me: // Customize the navigation controller The "correct answer" didn't work for me because I'm using UINavigationBar.appearance(). Your solution� In this Swift code snippet I demonstrate how we can customize UINavigationBar appearance via the AppDelegate.swift file. The blow code covers: Set UINavigationBar tint color Set Navigation bar Title colour Set navigation bar ItemButton tint colour Set Navigation bar background image Set navigation bar Back button tint colour @UIApplicationMain class AppDelegate: UIResponder

Swift 4:

For NavigationBar Background color:

UINavigationBar.appearance().barTintColor = UIColor(red: 50/255, green: 90/255, blue: 150/255, alpha: 1)

For NavigationBar title color and font:

let attrs = [
    NSAttributedStringKey.foregroundColor: UIColor.red,
    NSAttributedStringKey.font: UIFont(name: "Georgia-Bold", size: 24)!

UINavigationBar.appearance().titleTextAttributes = attrs

reference: here

Problem with barTintColor of Navig…, "your font name", size: 24)!, NSForegroundColorAttributeName : UIColor. whiteColor()] UINavigationBar.appearance().titleTextAttributes = attributesDictionary let tabbarAndNavBarBkg = UIImage (named: "nav_tab") UINavigationBar. appearance (). setBackgroundImage (tabbarAndNavBarBkg, forBarMetrics:. Default ) Or you can create a category on UIColor to return a UIImage given a UIColor instance, in objC:

For Swift 4.2

let color = UIColor.white
let font = UIFont(name: "Pacifico", size: 24)!

let attributes = [
  NSAttributedString.Key.font: font,
  NSAttributedString.Key.foregroundColor: color

UINavigationBar.appearance().titleTextAttributes = attributes

How to change navigation bar title color?, titleTextAttributes = [NSForegroundColorAttributeName: UIColor.orange] So you will have the same effect doing this: UINavigationBar.appearance(). ( changing the blue background color also does not work really good, see my other� In this video tutorial I am showing how to customize UINavigationBar by: changing its background color (barTintColor) set UINavigationBar Title text tint color (NSForegroundColorAttributeName) set UINavigationBar background image change Back button tint color change Bar Button item tint color Source code: // Set navigation bar tint / background colour UINavigationBar.appearance().barTintColor

put code in your AppDelegate file

let appTitlecolor = UIColor(red: 155.0/255.0, green: 204.0/255.0, blue: 67.0/255.0, alpha: 1.0)

UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName:UIFont(name: "Helvetica", size: 20)!, NSForegroundColorAttributeName: appTitlecolor]

How can I change the NavBar title text color in swift 4?, If you're setting title's in a navigation bar, you can customize the font, size and color of those titles by adjusting the titleTextAttributes attribute for� var navigationBarAppearace = UINavigationBar.appearance() navigationBarAppearace.tintColor = uicolorFromHex(0xffffff) navigationBarAppearace.barTintColor = uicolorFromHex(0x034517) In here tintColor attribute change the background color of the navigation bar barTintColor attribute affect to the color of the back indicator image button titles

iOS NavigationBar Style – Zendesk Develop, In this video tutorial I am showing how to customize UINavigationBar by: text tint color (NSForegroundColorAttributeName); set UINavigationBar background Your browser does not currently recognize any of the video formats available. titleTextAttributes = [NSForegroundColorAttributeName:UIColor. Questions: I am trying to fill the status bar background color to orange using the following UINavigationBar.appearance().tintColor = UIColor.orangeColor() UINavigationBar.appearance().barTintColor = UIColor.orangeColor() UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()] UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle

How to style the font in a UINavigationBar's title, titleTextAttributes = [ NSFontAttributeName: UIFont(name: "CaviarDreams", size: 20)!] iOS change navigation bar title font and color, custom navigation bar swift navigation var navigationBarAppearace = UINavigationBar.appearance() // Set Color let attributes: AnyObject = [ NSForegroundColorAttributeName: UIColor . I want it to be white. – user5483739 Jan 5 '16 at 1:37 UINavigationBar.appearance().tintColor = UIColor.whiteColor() should work.You must change the tintColor to other color somewhere in your code – Leo Jan 5 '16 at 2:04 @Leo This didn't work. – user5483739 Jan 5 '16 at 11:50

Customize UINavigationBar appearance in Swift, titleTextAttributes = [NSForegroundColorAttributeName: UIColor.redColor() Verified that this does work on Xcode 7.1.1+. UINavigationBar. appearance(). After encountering the same problem (as others) of the label that moves when we insert a button in the navBar (in my case i have a spinner that i replace with a button when the date is loaded), the above solutions didn't work for me, so here is what worked and kept the label at the same place all the time:

  • I think you could probably do this a little more simpler, but this did work. Thank you for explaining your answer as well as answering it!
  • @GeorgeB Yes it could be simpler (I realize I could have omitted the local variables altogether), but one of the main aims of the Swift programming language is to be very readable and clear. As such, code brevity isn't always the best choice. I also aim to be clear to stackoverflow readers who aren't as experienced with Swift and/or iOS and I think seeing a clear sequence of small steps can be helpful. Thank you for accepting the answer, glad it helped. :)