iOS中隐藏TabBar出现白条

隐藏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;
}

你可能感兴趣的:(iOS中隐藏TabBar出现白条)