How to hide the tabBar when push a view?

Sometimes the hidesBottomBarWhenPushed method hides the bottom bar with a choppy animation.

Instead I hide the tabbar in viewDidLoad with

self.tabBarController.tabBar.hidden = YES;

and restore its presence in viewWillDisappear

self.tabBarController.tabBar.hidden = NO;

use this methood in the UIViewController class where you want to hide the tabBarController

-(BOOL)hidesBottomBarWhenPushed
{
    return YES;
}

Update

As suggested by @Yuchen Zhong in his answer, This option is now available in the storyboard itself.

enter image description here


Set UIViewController.hidesBottomBarWhenPushed = YES when you want hide tab bar.

nextViewController.hidesBottomBarWhenPushed = YES;

You can do this in storyboard now:

  1. Select the UIViewController in your storyboard
  2. Select the checkbox Hide Bottom Bar on Push

enter image description here