隱藏TabBar常用方法:
self.hidesBottomBarWhenPushed = YES;
目前我在 @available(iOS 14.0, *) 會出現白條情況,其他系統暫未發現,隱藏之後下方會有白條,沒有找到具體復現路徑,原因大體是Controller的view的frame沒有及時更新導致,隱藏方法如下:
- (void)hiddenToolBar {
for (UIView *subView in [self.tabBarController.view subviews]) {
if (![subView isKindOfClass:[UITabBar class]]) {
CGRect mFrame = subView.frame;
mFrame.size.height = subView.frame.size.height + self.tabBarController.tabBar.frame.size.height;
subView.frame = mFrame;
} else {
[subView setHidden:YES];
}
}
return;
}
顯示方法如下:
- (void)showToolBar {
for (UIView *subView in [self.tabBarController.view subviews])
{
if (![subView isKindOfClass:[UITabBar class]])
{
CGRect mFrame = subView.frame;
mFrame.size.height = subView.frame.size.height - tarbarController.tabBar.frame.size.height;
subView.frame = mFrame;
[self.tabBarController.view setHidden:NO];
} else {
[subView setHidden:NO];
}
}
return;
}