在有Tabbar的页面A跳转到需要隐藏Tabbar的页面B,需要在B页面实现以下几个方法:
// 进入界面
- (void)viewWillAppear:(BOOL)animated {
[self setTabBarHidden:YES];
}
//离开界面
- (void)viewWillDisappear:(BOOL)animated {
[self setTabBarHidden:NO];
}
// 实现
- (void)setTabBarHidden:(BOOL)hidden{
UIView *tab = self.tabBarController.view;
if ([tab.subviews count] < 2) {
return;
}
UIView *view;
if ([[tab.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]]) {
view = [tab.subviews objectAtIndex:1];
} else {
view = [tab.subviews objectAtIndex:0];
}
if (hidden) {
view.frame = tab.bounds;
} else {
view.frame = CGRectMake(tab.bounds.origin.x, tab.bounds.origin.y, tab.bounds.size.width, tab.bounds.size.height);
}
self.tabBarController.tabBar.hidden = hidden;
}
网友评论