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;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章