Shantanu
Shantanu

Reputation: 3136

iphone+hide tabbar when any view is pushed

I am designing an app which has more than 4 options in tabbar,So all i want to do is to hide the tabbar when any view is being pushed and show it again when view is popped,I tried the hidesbottomwhenpushed but didn't work for me.Please help

Upvotes: 0

Views: 263

Answers (1)

Deepesh
Deepesh

Reputation: 8053

use this function

- (void) hideTabBar:(UITabBarController *) tabbarcontroller 
{
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.5];
        for(UIView *view in tabbarcontroller.view.subviews)
        {
            if([view isKindOfClass:[UITabBar 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)];
            }

        }

        [UIView commitAnimations];

 }

when you are call this function

[self hideTabBar:self. tabbarcontroller];

when you want to show the tabbarcontroller use this function

 - (void) showTabBar:(UITabBarController *) tabbarcontroller {

        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.5];
        for(UIView *view in tabbarcontroller.view.subviews)
        {
            NSLog(@"%@", view);

            if([view isKindOfClass:[UITabBar class]])
            {
                [view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];

        } 
        else 
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
        }


    }

    [UIView commitAnimations]; 
}

Upvotes: 1

Related Questions