How to hide tab bar with animation in iOS?

后端 未结 15 1925
夕颜
夕颜 2020-11-30 19:20

So I have a button that is connected to a IBAction. When I press the button I want to hide the tab bar in my iOS app with a animation. This [self setTabBarHidden:hidde

15条回答
  •  星月不相逢
    2020-11-30 20:09

    As per Apple docs, hidesBottomBarWhenPushed property of UIViewController, a Boolean value, indicating whether the toolbar at the bottom of the screen is hidden when the view controller is pushed on to a navigation controller.

    The value of this property on the topmost view controller determines whether the toolbar is visible.

    The recommended approach to hide tab bar would as follows

        ViewController *viewController = [[ViewController alloc] init];
        viewController.hidesBottomBarWhenPushed = YES;  // This property needs to be set before pushing viewController to the navigationController's stack. 
        [self.navigationController pushViewController:viewController animated:YES];
    

    However, note this approach will only be applied to respective viewController and will not be propagated to other view controllers unless you start setting the same hidesBottomBarWhenPushed property in other viewControllers before pushing it to the navigation controller's stack.

提交回复
热议问题