How to hide tab bar programmatically and then expand view to fit

前端 未结 5 655
余生分开走
余生分开走 2021-01-15 11:39

I got the code from this question: How to hide UITabBarController programmatically? which is brilliant, however the view doesn\'t expand to fit the space left by the tab bar

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-15 12:07

    -(void)hideTabBar
    {   UITabBarController * tabbarcontroller= appDelegate.tabBarVC;
            if (tabbarcontroller.tabBar.isHidden) 
        {
            return;
        }
        tabbarcontroller.tabBar.hidden=YES;
        CGRect frm=tabbarcontroller.view.frame;
        frm.size.height += tabbarcontroller.tabBar.frame.size.height;
        tabbarcontroller.view.frame=frm;
    }
    -(void)showTabBar
    {    UITabBarController * tabbarcontroller=appDelegate.tabBarVC;
        if (!tabbarcontroller.tabBar.isHidden)
        {
            return;
        }
        CGRect frm=tabbarcontroller.view.frame;
        frm.size.height -= tabbarcontroller.tabBar.frame.size.height;
        tabbarcontroller.view.frame=frm;
        tabbarcontroller.tabBar.hidden=NO;  
    }
    here appDelegate is = (AppDelegate *) [[UIApplication sharedApplication] delegate]
    tabBarVc is UITabBarController *tabBarVC defined as property in app delegate
    

提交回复
热议问题