UINavigationController Background Color UINavigationController Background Color

Boy today was a frustrating day.  Over the past month or so, when I have some free time at work I've been learning Objective C to create iPhone applications.

Today, I struggled and struggled to do the most simplistic thing ever and I wanted to share it with everyone so if you get stuck with the same problem, hopefully you will solve it a lot quicker than I did.

What I was trying to do was to change the background color of the "blue" navigation header.


Let me provide a bit of background information on what I was doing, so if you are having the same problem, you will solve it nice and quickly.

I have a UITabBarController defined in my app delegate.  Inside of there I create a UINavigationController and instantiate that with a UITableViewController that I have created.

Everything was working perfectly, then we wanted to change the blue to a red to match our logo.  Sounds easy enough right?  It sure is, when you know what you're doing.  I struggled thinking that it was part of the UITableViewHeader, found a couple of examples of that, but I couldn't get them working or looking like I wanted it to.

After some wasted time, I then realized that it is the UINavigationController that draws the blue background.  After some more trial and error and banging my head against the wall, I finally figured it out.  You simply do the following:

 navigationController.navigationItem.tintColor = [UIColor redColor];

That's it, now it's no longer blue!

Published on Mar 31, 2009

Tags: iPhone | UINavigationController

Related Posts

Did you enjoy this article? If you did here are some more articles that I thought you will enjoy as they are very similar to the article that you just finished reading.

Tutorials

Learn how to code in HTML, CSS, JavaScript, Python, Ruby, PHP, Java, C#, SQL, and more.

No matter the programming language you're looking to learn, I've hopefully compiled an incredible set of tutorials for you to learn; whether you are beginner or an expert, there is something for everyone to learn. Each topic I go in-depth and provide many examples throughout. I can't wait for you to dig in and improve your skillset with any of the tutorials below.