Fork me on GitHub

隐藏tabBar

- (void) hideTabBar:(BOOL) hidden{
    
    [UIView beginAnimations:nil context:NULL];
    if (hidden){

        [UIView setAnimationDuration:0];
    }
       else {
        [UIView setAnimationDuration:0];
    }

    for(UIView *view in self.tabBarController.view.subviews)
    {
        if([view isKindOfClass:[UITabBar class]])
        {
            if (hidden) {
                [view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
            } else {
                [view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
            }
        } 
        else 
        {
            if (hidden) {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
            } else {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
            }
        }
    }
    
    [UIView commitAnimations];
}

 

 

-(void)setTabBarHidden:(BOOL)bol{
if(bol == YES)//隐藏
{
[MenuTabBarCtrl.view setFrame:CGRectMake(0, 0, 320, 530)];
NSArray *views = [MenuTabBarCtrl.view subviews];
for(id v in views){
if([v isKindOfClass:[UITabBar class]]){
[(UITabBar *)v setHidden:YES];
}
}
}else {//显示
[MenuTabBarCtrl.view setFrame:CGRectMake(0, 0, 320, 480)];
NSArray *views = [MenuTabBarCtrl.view subviews];
for(id v in views){
if([v isKindOfClass:[UITabBar class]]){
[(UITabBar *)v setHidden:NO];
}
}
}

}



posted on 2012-03-25 11:53  pengyingh  阅读(170)  评论(0编辑  收藏  举报

导航