IOS隐藏和显示TabBar的方法
一》》系统tarbar
1.A------>B 隐藏tarbar
属性 hidesBottomBarWhenPushed
参考文献:http://www.isaced.com/post-223.html
1 self.hidesBottomBarWhenPushed = YES; 2 [self.navigationController pushViewController:AccountsViewC animated:YES]; 3 self.hidesBottomBarWhenPushed=NO;
二》》自定义tarbar
1.隐藏TabBar:
- - (void)hideTabBar {
- if (self.tabBarController.tabBar.hidden == YES) {
- return;
- }
- UIView *contentView;
- if ( [[self.tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] )
- contentView = [self.tabBarController.view.subviews objectAtIndex:1];
- else
- contentView = [self.tabBarController.view.subviews objectAtIndex:0];
- contentView.frame = CGRectMake(contentView.bounds.origin.x, contentView.bounds.origin.y, contentView.bounds.size.width, contentView.bounds.size.height + self.tabBarController.tabBar.frame.size.height);
- self.tabBarController.tabBar.hidden = YES;
- }
2.显示TabBar:
- - (void)showTabBar
- {
- if (self.tabBarController.tabBar.hidden == NO)
- {
- return;
- }
- UIView *contentView;
- if ([[self.tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]])
- contentView = [self.tabBarController.view.subviews objectAtIndex:1];
- else
- contentView = [self.tabBarController.view.subviews objectAtIndex:0];
- contentView.frame = CGRectMake(contentView.bounds.origin.x, contentView.bounds.origin.y, contentView.bounds.size.width, contentView.bounds.size.height - self.tabBarController.tabBar.frame.size.height);
- self.tabBarController.tabBar.hidden = NO;
- }
3.如果定义了上面两个方法,在viewDidAppear:方法里面就可以调用了
- -(void)viewDidAppear:(BOOL)animated{
- //[self hideTabBar];
- [self showTabBar];
- }

浙公网安备 33010602011771号