Sometimes, when using a UITabBarController
, you want to push a new view controller without the tab bar. Unfortunately, the default behaviour for a UITabBarController
is to show the tab bar no matter how many view controllers have been pushed.
Luckily, there is an easy way to elegantly hide the tab bar using the hidesBottomBarWhenPushed
property that every view controller has.
func moveToNextViewController() {
let vc = MyViewController()
vc.hidesBottomBarWhenPushed = true
navigationController?.pushViewController(vc, animated: true)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
self.hidesBottomBarWhenPushed = true
}
Thanks for reading, see you in the next article.