现在的位置: 首页 > 综合 > 正文

IOS – TabBarController 显示/隐藏第一级页面的TabBar

2018年02月02日 ⁄ 综合 ⁄ 共 534字 ⁄ 字号 评论关闭

- (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.view.frame = view.frame;

    self.tabBarController.tabBar.hidden = hidden;

}

抱歉!评论已关闭.