4

So I have an iPhone application running that is controlled at the highest level by a UITabBarController. It is the default black Tab Bar at the bottom that you see in many iPhone apps. I am kind of new to iPhone SDK programming, and I know I have seen other apps that have their own background color for the Tab Bar at the bottom. I am not sure if they are using this tab bar as I am, as the main controller for their app, but the question applies to this:

How do I change the background color of the main UITabBarController in my application? I wanted to change it to a dark shade of green similar to the colors of the navigation bars and labels I have placed in my app. I find it weird how Apple makes it really easy to change the color of Navigation Bars (not controllers), and other things, but when it comes to controllers (in this case a Tab Bar Controller), I cannot find a single way to implement this cleanly and efficiently.

RedBlueThing
  • 42,006
  • 17
  • 96
  • 122
Scott
  • 4,066
  • 10
  • 38
  • 54
  • 1
    Already answered here: http://stackoverflow.com/questions/675433/custom-colors-in-uitabbar (FYI, first Google answer for 'customizing style uitabbar'…) – Timothée Boucher Mar 04 '10 at 02:11

1 Answers1

5

You can do something like this.

- (void)viewDidLoad {
[super viewDidLoad];

CGRect frame = CGRectMake(0.0, 0, self.view.bounds.size.width, 48);

UIView *v = [[UIView alloc] initWithFrame:frame];

[v setBackgroundColor:[[UIColor alloc] initWithRed:1.0
                                           green:0.0
                                            blue:0.0
                                           alpha:0.1]];

[tabBar1 insertSubview:v atIndex:0];
[v release];
}
Legolas
  • 12,145
  • 12
  • 79
  • 132
Biranchi
  • 16,120
  • 23
  • 124
  • 161