8:02 pm | by olifarago

This is a follow up to the previous tutorial: How To Create a Custom Tab Bar (Part 2 of 2).  One question I have been asked over and over is how to hide your new custom tab bar once it is in place.  This is actually quite a simple process.

You can download a sample project containing the code to this article at GitHub: https://github.com/rumex/RXCustomTabBar

Before we start, I just want to say I know this is a messy way of doing things, it was simply done this way to illustrate the concepts behind this approach. One day when I have time I will create a proper standalone sub-class for custom tab bars. For now, please don’t moan at me on twitter.

Starting from where we left off at the end of the last tutorial, we will add two new methods to our RXCustomTabBar class called hideNewTabBar and showNewTabBar. To do this we will add the following to our RXCustomTabBar.h:

-(void) hideNewTabBar;
-(void) showNewTabBar;

We then add the new methods into our RXCustomTabBar.m file:

- (void)hideNewTabBar
self.btn1.hidden = 1;
self.btn2.hidden = 1;
self.btn3.hidden = 1;
self.btn4.hidden = 1;

- (void)showNewTabBar
self.btn1.hidden = 0;
self.btn2.hidden = 0;
self.btn3.hidden = 0;
self.btn4.hidden = 0;

Now when we want to hide our tab bar we simply call the methods from our View Controller using either:

[self.tabBarController hideNewTabBar]


[self.tabBarController showNewTabBar]

I have updated the code in the GitHub project so you can download the sample code complete with this new method here: https://github.com/rumex/RXCustomTabBar

5 Responses to “Hiding your New Custom Tab Bar (UITabBar) in an iPhone Application”

  1. aytunc says:

    thanks for sharing all these nice code. I would like to know if there is a way to dynamically add/remove tabbaritems from the tabbar which would be accepted by apple store. thanks

  2. vinhnn says:

    If I set background for the first view in black and then press hide tabbar button. There is an area not in black in place of tabbar => view’s bound not change=> not good. So how to hide tabbar and resize the frame of view drammatically.

  3. klfoong says:

    this does not work in iOS5 with Storyboard. is there any update on how to hide the tab bar in iOS5 from the above code?

  4. I know it’s about a year late, but if you just hide it with whatever code you use then do: self.view.frame = CGRectMake(0, 0, 320, 480 + 49); in customtabbar.m, it will extend the page to cover the blank spot

Leave a Reply

Videos, Slideshows and Podcasts by Cincopa Wordpress Plugin