跳转时添加隐藏
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
隐藏
[self makeTabBarHidden:YES];
调用系统隐藏方法, 防止三级页面显示tabBar
[segue.destinationViewController setHidesBottomBarWhenPushed:YES];
}
//在viewWillAppear里返回首页时取消隐藏
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self makeTabBarHidden:NO];
}
//自定义隐藏显示TabBar
- (void)makeTabBarHidden:(BOOL)hide{
if ( [self.tabBarController.view.subviews count] < 2 ){
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];
}
// [UIView beginAnimations:@"TabbarHide" context:nil];
if ( hide )
{
contentView.frame = self.tabBarController.view.bounds;
}
else
{
contentView.frame = CGRectMake(self.tabBarController.view.bounds.origin.x, self.tabBarController.view.bounds.origin.y, self.tabBarController.view.bounds.size.width, self.tabBarController.view.bounds.size.height - self.tabBarController.tabBar.frame.size.height);
}
self.tabBarController.tabBar.hidden = hide;
}