首先在自定义tabbar的时候,将tabbar直接加到系统上面
实现代码:
<strong><span style="font-family:SimHei;font-size:18px;color:#993300;background-color: rgb(255, 255, 255);"> //初始化定义tabbar的背景
_TabBarBG = [[UIImageView alloc] init];
_TabBarBG.frame = [self.tabBar bounds];
_TabBarBG.userInteractionEnabled = YES;
[_TabBarBG setImage:[UIImage imageNamed:@"tabbarbg"]];
[self.tabBar addSubview:_TabBarBG];
</span></strong>
在开发中如果在第一个页面中push到下一个页面的,并且想要隐藏tabbar
实现代码:
在push触发之前设置:setHidesBottomBarWhenPushed
<strong><span style="font-family:SimHei;font-size:18px;color:#993300;background-color: rgb(255, 255, 255);">- (void)pushView
{
[self setHidesBottomBarWhenPushed:YES];
OtherViewController *other = [[OtherViewController alloc]init];
[self.navigationController pushViewController:other animated:YES];
}
</span></strong>
之后在同时加入:
<strong><span style="font-family:SimHei;font-size:18px;color:#993300;background-color: rgb(255, 255, 255);">- (void)viewWillDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[self setHidesBottomBarWhenPushed:NO];
}
</span></strong>
这样就可以隐藏tabbar,由于我们自定一的tabbar是直接加在系统默认的tabbar上面的。所以这样一来,既能够隐藏自定义的tabbar也可以直接隐藏系统默认的tabbar。