In my iPhone app I have implemented a custom tab bar which functions perfectly, no problems there. However, there is one problem that I’m encountering: Basically my custom tab bar doesn’t actually control the tab bar views, it just signals the underlying standard UITabBarController that it should setSelectedIndex:1, etc. It’s basically only a visual custom tab bar without any logic behind it. Therefore, I need to hide the underlying standard UITabBar that does all of the dirty work behind the scenes.
The most common thing I’ve come across with my friend Google is that people have used this code to hide the tab bar:
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[AppTabBarController_iPhone class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
Indeed, this does push the tab bar just out of sight, but it brings along another problem in any scroll views: The background image of every scrollview is getting repeated for 44 pixels (i.e. the height of the tab bar that has been shifted down) and so that makes for a truly ugly experience.
Is there some sort of setFrame hack I can do to make this work out, or do you have a completely better way of hiding the tab bar that would eradicate this problem?
Just a thought, instead of hiding the original UITabBar why don’t you just cover it with your custom UITabBar? Unless they have different heights you should be just fine.
To cover it you would have to add your custom tabbar as a subview to the main window.