How to Change Navigation Bar Color in iOS 7

Changing navigation bar color in Swift

Navigation Bar:

navigationController?.navigationBar.barTintColor = UIColor.green

Replace greenColor with whatever UIColor you want, you can use an RGB too if you prefer.

Navigation Bar Text:

navigationController?.navigationBar.titleTextAttributes = [.foregroundColor: UIColor.orange]

Replace orangeColor with whatever color you like.

Tab Bar:

tabBarController?.tabBar.barTintColor = UIColor.brown

Tab Bar Text:

tabBarController?.tabBar.tintColor = UIColor.yellow

On the last two, replace brownColor and yellowColor with the color of your choice.

iOS 7 Navigation Bar text and arrow color

Behavior from some of the properties of UINavigationBar has changed from iOS 7. You can see in the image shown below :

Sample Image


Two beautiful links I'd like to share with you. For more details you can go through these links :

  1. iOS 7 UI Transition Guide.
  2. How to Update Your App for iOS 7.

Apple Documentation for barTintColor says :

This color is made translucent by default unless you set the
translucent property to NO.

Sample Code :

self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
[self.navigationController.navigationBar
setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
self.navigationController.navigationBar.translucent = NO;

Change navigation bar tint color iOS 7.

you can add bellow code in appdelegate.m

  if your app is navigation based

// for background color
[nav.navigationBar setBarTintColor:[UIColor blueColor]];

// for change navigation title and button color
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, [UIFont fontWithName:@"FontNAme" size:20], NSFontAttributeName, nil]];

[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];

How do I change the colour of the status bar when the navigation bar is hidden in iOS 7?

Add a UIView under the status bar and set its backgroundColor property to the navigation bars barTintColor

Navigation Bar color doesn't change back? iOS7

Put that in viewWillAppear:. Code in this method will be run every time the view reappear.

Unable to change navigation bar color

There are two ways to do this. You can either modify the appearance proxy that you have set up in the AppDelegate for the whole app, or you can modify the individual navigationbar for the particular screen.

When you dismiss the view - you need to reset the barTintColor in the viewWillDisappear.

override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)

// Set to new colour for whole app
UINavigationBar.appearance().barTintColor = UIColor.blueColor()

// Or, Set to new colour for just this navigation bar
self.navigationController?.navigationBar.barTintColor = UIColor.blueColor()
}

override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)

//Revert to old colour, whole app
UINavigationBar.appearance().barTintColor = UIColor.redColor()

//Revert to old colour, just this navigation bar
self.navigationController?.navigationBar.barTintColor = UIColor.redColor()
}


Related Topics



Leave a reply



Submit