title: Swift Tab bar hidden but custom button still active
body: <p>I have a custom tab Bar where i add a button in the middle:</p>
  
  <pre><code>class CustomTabBarController: UITabBarController {
  
   override func viewDidLoad() {
      super.viewDidLoad()
  
      setupMiddleButton()
  }
  func setupMiddleButton() {
      let numberOfItems = CGFloat(tabBar.items!.count)
      let tabBarItemSize = CGSize(width: tabBar.frame.width / numberOfItems, height: tabBar.frame.height)
      menuButton.frame = CGRect(x: 0, y: 0, width: tabBarItemSize.width, height: tabBar.frame.size.height)
      var menuButtonFrame = menuButton.frame
      menuButtonFrame.origin.y = self.view.bounds.height - menuButtonFrame.height - self.view.safeAreaInsets.bottom
      menuButtonFrame.origin.x = self.view.bounds.width/2 - menuButtonFrame.size.width/2
      menuButton.frame = menuButtonFrame
      menuButton.backgroundColor = UIColor.clear
      menuButton.addTarget(self, action: #selector(menuButtonAction), for: UIControlEvents.touchUpInside)
      self.view.addSubview(menuButton)
      self.view.layoutIfNeeded()
  }
  override func viewDidLayoutSubviews() {
      super.viewDidLayoutSubviews()
      menuButton.frame.origin.y = self.view.bounds.height - menuButton.frame.height - self.view.safeAreaInsets.bottom
   }
  }
  </code></pre>
  
  <p>This bar is shown in multiple controller.</p>
  
  <p>However i have a specific controller where i'd like the tab bar to be hidden.</p>
  
  <pre><code> override func viewWillAppear(_ animated: Bool) {
      super.viewWillAppear(animated)
      self.tabBarController?.tabBar.isHidden = true
  
  }
  override func viewWillDisappear(_ animated: Bool) {
      super.viewWillDisappear(animated)
      self.tabBarController?.tabBar.isHidden = false
  }
  </code></pre>
  
  <p>This code works fine and the bar is actually hidden.</p>
  
  <p>However If i click in the middle (where the menuButton is added) the button action is called (a segue is performed).</p>
  
  <p>How can I disable the button when hiding the Tab bar?</p>
  
  <p>Thank you for the help!
  --------------UPDATE Solution
  I am not sure this is the best solution because i'm new to swift, but it seems to work...
  in my CustomTabBarController I have added to function:</p>
  
  <pre><code>func hideTabBar() {
      self.tabBar.isHidden = true
      self.menuButton.isHidden = true
  }
  
  func showTabBar() {
      self.tabBar.isHidden = false
      self.menuButton.isHidden = false
  }
  </code></pre>
  
  <p>the whenever i need to hide/display it i call this functions.</p>
  
  <p>In my case in the controller where i'd like to hide it i do so:</p>
  
  <pre><code>  override func viewWillAppear(_ animated: Bool) {
      super.viewWillAppear(animated)
      let tabBar = self.tabBarController as! FishBookTabBarController
      tabBar.hideTabBar()
  
  }
  override func viewWillDisappear(_ animated: Bool) {
      super.viewWillDisappear(animated)
       let tabBar = self.tabBarController as! FishBookTabBarController
      tabBar.showTabBar()
  }
  </code></pre>