跳轉(zhuǎn)時添加隱藏
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
隱藏
[self makeTabBarHidden:YES];
調(diào)用系統(tǒng)隱藏方法, 防止三級頁面顯示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;
}