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

来源:互联网 发布:石鑫台球网络教学 编辑:程序博客网 时间:2024/06/09 08:19

- (void)setTabBarHidden:(BOOL)hidden

{

    UIView *tab =self.tabBarController.view;

    

    if ([tab.subviewscount] < 2) {

        return;

    }

    UIView *view;

    

    if ([[tab.subviewsobjectAtIndex:0]isKindOfClass:[UITabBarclass]]) {

        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;

}

0 0
原创粉丝点击