隐藏tabbar ,iOS 11 之后使用tabbar.hidden 无效了,在push或者preson 页面之后会自动又显示出tabbar ,不知道为什么 ,在ios10之前不会 ,解决方法如下:
- (void)hideTabBar {
if (self.tabBarController.tabBar.hidden == YES) {
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];
contentView.frame = CGRectMake(contentView.bounds.origin.x, contentView.bounds.origin.y, contentView.bounds.size.width, contentView.bounds.size.height + self.tabBarController.tabBar.frame.size.height);
self.tabBarController.tabBar.hidden = YES;
}
直接将此方法放到mainController 的 viewWillAppear 里面.达到隐藏的效果 .