Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide UITabBarController programmatically?

Is it possible to hide it with animation ?

like image 501
RAGOpoR Avatar asked Feb 13 '10 10:02

RAGOpoR


4 Answers

A UITabBar inherits from UIView, so you can hide it and animate it like you would with a standard UIView.

- (void) hideTheTabBarWithAnimation:(BOOL) withAnimation {
    if (NO == withAnimation) {
        [theTabBar setHidden:YES];
    } else {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDelegate:nil];
        [UIView setAnimationDuration:0.75];

        [theTabBar setAlpha:0.0];       

        [UIView commitAnimations];
    }
}
like image 100
Guillaume Avatar answered Oct 06 '22 07:10

Guillaume


You should use this code:

self.tabBarController.tabBar.hidden=YES;
like image 38
Pratik Patel Avatar answered Oct 06 '22 08:10

Pratik Patel


-(void)hideTabBar
{   UITabBarController * tabbarcontroller= appDelegate.tabBarVC;
        if (tabbarcontroller.tabBar.isHidden) 
    {
        return;
    }
    tabbarcontroller.tabBar.hidden=YES;
    CGRect frm=tabbarcontroller.view.frame;
    frm.size.height += tabbarcontroller.tabBar.frame.size.height;
    tabbarcontroller.view.frame=frm;
}
-(void)showTabBar
{    UITabBarController * tabbarcontroller=appDelegate.tabBarVC;
    if (!tabbarcontroller.tabBar.isHidden)
    {
        return;
    }
    CGRect frm=tabbarcontroller.view.frame;
    frm.size.height -= tabbarcontroller.tabBar.frame.size.height;
    tabbarcontroller.view.frame=frm;
    tabbarcontroller.tabBar.hidden=NO;  
}
here appDelegate is = (AppDelegate *) [[UIApplication sharedApplication] delegate]
tabBarVc is UITabBarController *tabBarVC defined as property in app delegate
hope this helps
like image 35
Tanuj Jagoori Avatar answered Oct 06 '22 09:10

Tanuj Jagoori


You can also hide it using the attributes inspector:

enter image description here

but not with an animation.

like image 40
hanumanDev Avatar answered Oct 06 '22 09:10

hanumanDev