Changing the default background color of the UITabBarController

So, I have an iPhone app that is supervised with the UITabBarController. This is the default black tab bar that you see in many iPhone apps. I am partly new to programming the iPhone SDK, and I know that I have seen other applications that have their own background color for the tab bar below. I'm not sure that they use this tab bar, like me, as the main controller for their application, but the question relates to this:

How to 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 shortcuts that I placed in my application. It seemed strange to me how Apple very easily changes the color of navigation bars (not controllers), etc., but when it comes to controllers (in this case, the tab bar controller), I cannot find any way to implement this cleanly and efficiently.

+4
source share
1 answer

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]; } 
+5
source

Source: https://habr.com/ru/post/1303066/


All Articles