Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Steven Rayzman
2,423 PointsNavigation Item
How can I change the color of the Navigation Item using swift? Stone Preston Stephen Whitfield

Steven Rayzman
2,423 Pointsthe back button
4 Answers

Stephen Whitfield
16,771 PointsI actually misled you a bit. The bar buttons added in Storyboard are custom buttons and you wouldn't get the back bar button that you get for free from creating a navigation stack. You'd have to create your own back bar button indicator image and explicitly define a method that pops the current view off the nav stack and assign it to this custom button, but lets not do all of that. Just stick with the code I gave you earlier and put it in your "viewWillAppear" method.

Steven Rayzman
2,423 PointsThank you so much, it worked perfectly! Happy holidays.

Stephen Whitfield
16,771 Points- Set the tintColor of the nav bar to the color you want to use for the back bar button, then set the back bar button.
self.navigationController?.navigationBar.tintColor = UIColor.redColor()
self.navigationItem.backBarButtonItem?.tintColor = UIColor.redColor()

Stephen Whitfield
16,771 PointsIf you are adding bar buttons in Storyboard, you have the luxury of setting the bar buttons each to whichever color you choose in the attributes inspector. Are you Storyboarding or building this app programmatically?

Steven Rayzman
2,423 PointsI am storyboarding, but the back button only shows in the simulator, and I am unsure of how to select it in the storyboard. Could you tell me how? Stephen Whitfield

Stone Preston
42,016 PointsWhat do you mean by navigation item exactly? The whole navigation bar text? the back button only?
if you want the color to be application wide you should put it in the app delegate under did finish launching with options using the UIAppearance proxy
UINavigationBar.appearance().tintColor = SomeColorHere
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: SomeColorHere]

Steven Rayzman
2,423 PointsSorry, I meant the back button. Stone Preston
Nick Janes
5,487 PointsNick Janes
5,487 PointsNavigation Item?