This question already has an answer here:
-
UITabBar fully transparent
1 answer
I have spent the last few hours trying to get the TabBar in a UITabBarController fully transparent (clear background). I use a custom subclass of the UITabBarController and I managed to change the tintColor, the alpha, but the background color definitely remains the one defined in IB.
Thanks for your help, I'm getting crazy...
Here is one way to accomplish that.
CGRect frame = CGRectMake(0.0, 0.0, 320, 48);//Setting a Frame.
myTabView = [[UIView alloc] initWithFrame:frame];//Making Tab View
// not supported on iOS4
UITabBar *tabBarr = [self.tabBar tabBar];
if ([tabBarr respondsToSelector:@selector(setBackgroundImage:)])
{
// set it just for this instance
[tabBarr setBackgroundImage:[UIImage imageNamed:@"hot-1.png"]];
// set for all
// [[UITabBar appearance] setBackgroundImage: ...
}
else
{
// ios 4 code here
//[tabBarr setBackgroundColor:c];
}
//[myTabView setBackgroundColor:c];//Setting Color Of TaBar.
[myTabView setAlpha:0.8];//Setting Alpha of TabView.
[[self.tabBar tabBar] insertSubview:myTabView atIndex:0];//Inserting Tab As SubView.
And here is a link to a tutorial I found very useful in changing the tab bar's background. You can play around with the code and costomize it to your liking.
http://ios-blog.co.uk/tutorials/how-to-customize-the-tab-bar-using-ios-5-appearance-api/
Edit:
As far as setting the background color of tabbar to transparent or clear color, you have two ways. One is the image which I explained and you didn't like. The other one is to set the background of tabbar in its supper view. Something along the following line.
tabBar.superview.backgroundColor = [UIColor clearColor];
This way you reach behind the tabbar and change that black background to whatever you want.
Edit 1:
sorry for delay in adding the solution for ios 7. below is the method you need to change the background color of the tabbar in ios 7.
just add the following line of code inside your ViewDidLoad
method and it will do the magic.
[self.tabBarController.tabBar setBackgroundColor:[UIColor greenColor]];
hope this helps.:)