views:

944

answers:

1

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.

A: 
  • (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]; }

Biranchi