UITabBarController 隐藏标签栏

来源:互联网 发布:网络文明调查问卷 编辑:程序博客网 时间:2024/06/05 16:06

I am pasting this from my working code... you can call these methods to hide and show the tabbarcontroller.... just pass tabbarcontroller instance to these functions..

[self hideTabBar:self.tabBarController];

- (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];}- (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]; }

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

[self.tabBarController.tabBar setHidden:YES];


转帖:http://stackoverflow.com/questions/5272290/how-to-hide-uitabbarcontroller