change navigation bar color of specific controller - ios

I have set a color of my Navigation bar in Appdelegate so my app uses same color for all the navigation appearing in different screens. But Now for one or two controllers I want to change the navigation color. I used this code in viewDidLoad of specific controller but It isn't working
self.navigationController?.navigationBar.backgroundColor = UIColor.whiteColor()
I have tried this code in viewWillAppear function too but still it doesn't work

The property you are looking for is not backgroundColor, but rather barTintColor.
self.navigationController?.navigationBar.barTintColor = UIColor.whiteColor()

Please use tint color
[nav.navigationBar setBarTintColor:[UIColor blueColor]];

Related

NavigationBar barTintColor showing different effect for same color

I am trying to set color to navigation bar for different controllers but same color showing different effect.
Add following line to your viewDidLoad:method of navigationController class,
self.navigationBar.translucent = NO;
Visit navigationBar translucent property.

View Controller Top Bar not editing

In my view controller, I have changed the color of the top bar in the simulated metrics, I have changed it to be 'Translucent Black navigation bar', but when I start up my app in the simulator my top bar is still white.
BarSimulated metrics only affect how the NavigationBar's overview is displayed in the Interface Builder. The actual NavigationBar is either part of your viewController's navigationController or a view you added manually.
With UINavigationcontroller:
self.navigationcontroller.navigation.translucent = false
With custom UINavigationBar:
self.myNavigationBar.translucent = false
Try setting the NavigationBar tint colour as following screenshot.
Simulated metrics exist just that you can see what it will look like on launch. It doesn't really affect your app.
If you want to change your navigationBar's color, you must do it programmatically:
SWIFT
// in ViewController
navigationController.navigationBar.barTintColor = UIColor.greenColor()
OBJ C
// in ViewController
self.navigationBar.barTintColor = [UIColor greenColor];

Is there a way to change the back button color when using the navigation controller in Xcode [duplicate]

I'm having problems trying to figure out how to change the color of the buttons on the navigation controller.
Previously I had used the following:
[[UIBarButtonItem appearance] setTintColor:[UIColor colorWithRed:226/255.0 green:66/255.0 blue:66/255.0 alpha:0.0]];
and this worked, but I added a new view with a toolbar, and the tool bar button images will not show. If I remove the global coloring, the tool bar items show just fine.
I've tried setting the tint color on both the leftBarButtonItem and the backBarButtonItem in the viewDidLoad method of the view, but both of those properties appear to be null.
I don't want to change the color of the entire navigation bar, just the buttons. Is there a way to do this?
Yeah, I'll just post this as an answer. Your alpha is set to 0. So you're basically saying the same thing as [UIColor clearColor].
Not sure how that ever worked to give you a tint color on your bar button items.
In swift, it can be accomplished by the following command:
if let navController = self.navigationController
{
navController.navigationBar.tintColor = UIColor.whiteColor()
}

Changing the colour of Navigation Controller bottom toolBar

I am trying to change the colour of the bottom bar of my Navigation Controller. I have managed to change the top NavBar in my appdelegate by adding
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.688 green:0.437 blue:0.794 alpha:1.0]];
I want to apply this to the bottom bar also.
You can use [UIToolbar appearance] to set the appearance of UIToolbar
Good luck
I had the same problem, but could escape this by setting a tag for my navigationBar in my storyboard. Then I could change the navigationBar's color like this:
let navigationBar = (self.view.viewWithTag(someNumber) as UINavigationBar)
navigationBar.barTintColor = UIColor.blackColor()
This is not ideal unless you can guarantee that the number of subviews in your view is less than "someNumber". If you can though, then this should work.

Change to color of back button

When I configured a segue from a table view cell to another VC which embedded in a nav Controller, there was a little back button(blue color) in the nav bar, i did not add any bar buttons in my story boards, but i want its color to be white. I have tried the following code:(in my viewDidLoad() method)
UIBarButtonItem.appearance().tintColor = UIColor.whiteColor()
and this:
self.navigationController.navigationBar.tintColor = UIColor.whiteColor()
or any other similar codes...they were all not working.
Can anyone help me out?
If you set the global tint color in the storyboard, it will affect the color of the back button.

Resources