UINavigationController Background Color

U

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!

Other useful articles

About the author

By Jamie

My Books