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! While you're at it, check out some resources Treehouse students have shared here.

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

iOS

Changing the background color for the navigation bar of a navigation controller

I'm trying to figure out how to change the background to the navigation bar so I can have it match the color scheme of my app. Ex how Twitter has the whole top background a baby blue color, that is basically exactly what I'm looking to do.

5 Answers

Hey Marlon,

I did a quick search on Stack Overflow and came up with this:

Stack Overflow

It's in Obj-C, but it'll be helpful either way, I think. Let me know if you need additional clarification.

Good luck, Kyle

I think this is just for a image at the top. I could be mistaken, it's how I'm taking it, yes clarification would be nice thank you lol.

Haha no problem. Changing the color is hidden in there a little bit. I'll have time later today or tomorrow and I can give you a more complete rundown then.

Kyle

Thank you sir.

Hey Marlon,

I wanted to let you know, I haven't forgotten about your question, but this last week has been crazy as will the next few days. Let me know if you're able to find the answer online, but if not, I'll get an answer to you as soon as I can.

Thanks, Kyle

It's cool, trust I understand...Yeah I have not been able to find anything yet, still looking...thank you sir.

Alrighty Marlon, I definitely owe you an answer now. Turns out I had to do this today, and that reminded me that I needed to get back to you on it. Here are a couple Stack Overflow articles on it that should help:

(1) http://stackoverflow.com/questions/18177010/how-to-change-navigation-bar-color-in-ios-7-or-6/18870519#18870519 (2) http://stackoverflow.com/questions/26008536/ios-8-navigationbar-bar-tint-and-title-text-color-swift

I've uploaded a full working example here: https://github.com/kbpontius/UINavigationControllerExample

-- You're welcome to download the project and play around with it to see how updating the Navigation Controller works.

-- Please note that I'm using the Storyboard with a Navigation Controller from the Interface Builder.

-- (See "Screenshot" folder in the Github project) Select the Table View Controller > Go to "Attributes Inspector" > Under "Custom Class", set it to the class file name you created or when you code the background color change it won't work. That file must implement UITableViewController.

Please let me know if you have any questions about the project Marlon. Good luck!

Kyle