0

When hiding the tab bar either by:

self.tabBarController?.tabBar.isHidden = true

or

self.tabBarController?.tabBar.layer.zPosition = -1

The tab bar hides as expected but it still responds to touches and toggles the tab. How do I prevent that from happening?

I want the Tab Bar to appear when the view loads and only hide it during a specific mode then unhide it again so any answers that involve hiding / removing the tab bar prior to load won't help unfortunately.

For some background information, what I am trying to achieve can be thought of as a custom ActionSheet. It comes up from the bottom and I want to utilise the bottom space as much as possible hence hiding the tab bar. The user can then dismiss the action sheet and the tab bar reappears.

Michael Hudson
  • 1,330
  • 4
  • 21
  • 25

2 Answers2

0

You can disable with this line of code,

self.tabBar.isUserInteractionEnabled = false
Kamran
  • 14,987
  • 4
  • 33
  • 51
0

if you need to hide and disable the tab bar use this

self.tabBarController?.tabBar.isHidden = true
self.tabBarController?.tabBar.isUserInteractionEnabled = false

and If you need to hide it on a Push, add like this while you push to a desired VC.

let objCreateEventVC = CreateEventVC()
objCreateEventVC.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(objCreateEventVC, animated: false)
Vicky_Vignesh
  • 584
  • 2
  • 14