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

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

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

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

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.

iOS - How to change color of icons in tab bar moreViewController

I want to change color of icons (and probably badge) in moreNavigationController from gray to something else.
I've read and successfully changed color of background and text. I did this by "replacing" data source of moreViewController (described e.g. here Customizing the More menu on a Tab bar ). But updating icons (also textLabel value) here makes no effect. Is it possible to change this gray color to white (or anything else)? Or I have to implement my own tabBarController? (any good tutorials?)
PS. I know how to change icons on tab bar itself, the question is how to do this in moreViewController?
Thanks!
Piotr
In case it is still relevant to anyone.
You can change icon colors displayed in a tableView of moreViewController:
self.tabBarController?.moreNavigationController.topViewController?.view.tintColor = UIColor.redColor()
Changing a title is like so:
self.tabBarController?.moreNavigationController.navigationBar.topItem?.title = "MyString"
Changing Edit button:
self.tabBarController?.moreNavigationController.navigationBar.tintColor = UIColor.redColor()
You can do this using the appearance proxy, new in iOS 5. In your app delegate's didFinishLaunching method:
[[UITabBar appearance] setSelectedImageTintColor:[UIColor redColor]];
In iOS 7 use:
[[UITabBar appearance] setTintColor:[UIColor redColor]];
See the UITabBar class reference for more details.
Ok, from long research on the web and answers in this thread, it seems that it is not possible on iOS7 to change color of the icons (gray color) displayed in moreViewController of UITabBarController. The best solution for customizable tab bar is to implement it (or use some library).
Thanks!
You can change the color, just subclass the tab bar controller and in it's view did load add the below code
override func viewDidLoad() {
super.viewDidLoad()
var view = self.moreNavigationController.topViewController.view as UITableView
view.tintColor = Utilities.mainColor()
view.separatorStyle = .None
}
For more you can see my question here : Change tint color of tabbar edit view controller

Resources