Change to color of back button - ios

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.

Related

when navigationBar.isTranslucent is true, the backgroundImage of navigationbar become translucent too

In my first page, the navigation bar should be transparent, and when push to next page, the navigation bar should be a image. I worked it out by changing the _UIBarBackground or _UINavigationBarBackground's alpha.
But I meet a big problem, in the first page, view should be placed and draw from (0,0) so I set the navigation bar's isTranslucent to true, that all works fine. But when I enter the next page, background image shows with a translucent looking which I don't want.
btw, I set background using:
navVC.navigationBar.setBackgroundImage(UIImage(named: "navigation_bar_background"),
for: .default)
I checked the image used here, and it's not translucent.
What can I do with this issue? I don't want set viewController's extendedLayoutIncludesOpaqueBars to true due to ugly appearance when animation.
Combination of these 2 solutions will help.
http://ioscodeguide.blogspot.in/2014/01/navigation-bar-bagground-image.html
http://ioscodeguide.blogspot.in/2014/01/navigation-bar-font-style-and-font.html
In first view:
self.navigationController.navigationBar.tintColor = [UIColor clearColor];
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
In 2nd view:
Set image to your navigationBar using the following link.
How to set Navigation Bar Bagground image - By - iOSCodeGUIDE
Adding to that
To keep navigation bar transparent in first page and display on 2nd page,
1st Page viewwill appear Hide-Yes NavigationBarHide, and on view did disappear Hide-No

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];

change navigation bar color of specific controller

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]];

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()
}

Is it possible to change navigation bar color when I press a uibutton?

I'm wondering if its possible to change the color of Ui Navigation Bar color in Swift 2? Imagine whatsapp white color is changable to any color as the user press a button in settings for example. I have Googled for this online but didn't find anything.
Thanks.
In your buttons action just add
// UINavigationItem buttons
self.navigationController?.navigationBar.tintColor = UIColor.blueColor()
// NavigationBar color
self.navigationController?.navigationBar.barTintColor = UIColor.greenColor()
You can use the UINavigationBar's property barTintColor.
Documentation: UINavigationBar Class Reference

Resources