iOS开发小知识--页面跳转后隐藏Tabbar视图

在有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;

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容