I have a navigation controller. For one of the views i want to hide the bottom tab bar, so it gets the max possible screen real estate. To do this, i have:
-
I'm have solved this problem like that:
Almost all my ViewControllers are children of BaseViewController.
So, example:
class BaseVC: UIViewController {
final override var hidesBottomBarWhenPushed: Bool {
get {
if navigationController?.viewControllers.last == self {
return prefersBottomBarHidden ?? super.hidesBottomBarWhenPushed
} else {
return false
}
} set {
super.hidesBottomBarWhenPushed = newValue
}
}
private(set) var prefersBottomBarHidden: Bool?
}
Just override variable "prefersBottomBarHidden" in ViewController where BottomBar should be hidden:
override var prefersBottomBarHidden: Bool? { return true }