隐藏Tabbar

当前页面隐藏:

- (void)setTabBarHidden:(BOOL)hidden
{
  if (self.tabBarController.tabBar.hidden == hidden) {
		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];

  CGFloat height = 0.0f;
  if (hidden)
    height = contentView.bounds.size.height + self.tabBarController.tabBar.frame.size.height;
  else
    height = contentView.bounds.size.height - self.tabBarController.tabBar.frame.size.height;

	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 = hidden;
}

push隐藏:

self.hidesBottomBarWhenPushed = YES;

Leave a Reply

Your email address will not be published.