6

I want to change the navigation bar tint controller colour to the colour: R: 73, G: 155, B: 255, A: 0.7

Till now, I have only been able to change it to the colours in the system. Here is an example in the Delegate:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {

    UINavigationBar.appearance().barTintColor = UIColor.blueColor()
    UINavigationBar.appearance().tintColor = UIColor.whiteColor()

    return true
}

Also, I would like to be able to change the navigation view controller title colour to white too!

If it is possible I want to change the tab bar tint colour to R: 73, G: 155, B: 255, A: 0.7 and their texts to white.

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
Arafat Qureshi
  • 101
  • 4
  • 11

1 Answers1

11

If you want to set the background color of the nav bar:

UINavigationBar.appearance().barTintColor = UIColor.redColor()

Note RGB values are from 0.0 to 1.0 so you have to divide them by 255 or your color will just be white. Next tint:

UINavigationBar.appearance().tintColor = UIColor(red: 73.0 / 255.0, green: 155.0 / 255.0, blue: 255.0/ 255.0, alpha: 1.0)

Then to set your title text:

UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: someColor, NSFontAttributeName: someFont]

Finally for bar button items:

UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: color, NSFontAttributeName: buttonFont], forState: UIControlState.Normal)
Ian
  • 12,538
  • 5
  • 43
  • 62
  • thanks for that! how do I change the colour of the UITabBar images from the grey to white when un-selected and my own RGBA value when selected? – Arafat Qureshi Dec 13 '14 at 08:24
  • Okay, I opened a new question: http://stackoverflow.com/questions/27466919/change-colour-of-unselected-tab-bar-icon-in-swift and made this answer accepted @Bluehound – Arafat Qureshi Dec 14 '14 at 06:29