title: Tab bar item not highlighted when a tab is selected programmatically with custom tab bar
body: <p>I have a custom tab bar that has a bigger tab bar item at the center.</p>
  
  <p>If I use the custom tab bar and programmatically select a tab, tab bar item wont be highlighted. It will only be highlighted when I press the tab manually:</p>
  
  <pre><code>    let controller1 = ....
      controller1.tabBarItem = UITabBarItem(..)
  
      let controller2 = ...
      controller2.tabBarItem = UITabBarItem(..)
  
      let controller3 = ...
      controller3.tabBarItem = UITabBarItem(..)
  
      let controller4 = ...
      controller4.tabBarItem = UITabBarItem(..)
  
      let tabBarController = UITabBarController()
      tabBarController.viewControllers = [controller1, controller2, controller3, controller4];
  
      let myTabBar = MainTabBar()
      tabBarController.setValue(myTabBar, forKey: "tabBar")
      tabBarController.selectedIndex = 0 //tab bar item wont highlight!
  
      self.window?.rootViewController = tabBarController;
      self.window?.makeKeyAndVisible()
  </code></pre>
  
  <p>However, if I remove the custom tab bar, it works:</p>
  
  <pre><code>    let controller1 = ....
      controller1.tabBarItem = UITabBarItem(..)
  
      let controller2 = ...
      controller2.tabBarItem = UITabBarItem(..)
  
      let controller3 = ...
      controller3.tabBarItem = UITabBarItem(..)
  
      let controller4 = ...
      controller4.tabBarItem = UITabBarItem(..)
  
      let tabBarController = UITabBarController()
      tabBarController.viewControllers = [controller1, controller2, controller3, controller4];
  
      //let myTabBar = MainTabBar()
      //tabBarController.setValue(myTabBar, forKey: "tabBar")
      tabBarController.selectedIndex = 0 //tab bar item WILL highlight!
  
      self.window?.rootViewController = tabBarController;
      self.window?.makeKeyAndVisible()
  </code></pre>
  
  <p>This is my custom tab bar, to implement a bigger center button:</p>
  
  <pre><code>import UIKit
  
  class MainTabBar: UITabBar {
  
  private var middleButton : UIButton?
  var middleButtonPressed: ()-&gt;() = {}
  
  override func hitTest(_ point: CGPoint, with event: UIEvent?) -&gt; UIView? {
      guard let middleButton = middleButton else {
          return super.hitTest(point, with: event)
      }
      if self.isHidden {
          return super.hitTest(point, with: event)
      }
  
      let from = point
      let to = middleButton.center
  
      return sqrt((from.x - to.x) * (from.x - to.x) + (from.y - to.y) * (from.y - to.y)) &lt;= 39 ? middleButton : super.hitTest(point, with: event)
  }
  
  func showMiddleButton() {
      if middleButton == nil {
          let size : CGFloat = 48.0
          middleButton = UIButton(frame: CGRect(x: 0.5 * (self.bounds.size.width - size), y: 10.0 - size, width: size, height: size))
          if let middleButton = middleButton {
              middleButton.backgroundColor = ThemeManager.currentTheme().mainColor
              middleButton.layer.shadowOffset = CGSize(width: 0, height: 5)
              middleButton.layer.shadowOpacity = 1
              if middleButton.backgroundColor == UIColor.white {
                  middleButton.layer.shadowColor = UIColor(red:0.14, green:0.06, blue:0.21, alpha:0.86).cgColor
                  middleButton.layer.shadowRadius = 28
              }else{
                  middleButton.layer.shadowColor = UIColor(red:0.14, green:0.06, blue:0.21, alpha:0.29).cgColor
                  middleButton.layer.shadowRadius = 20
              }
              middleButton.layer.cornerRadius = 0.5 * size
              middleButton.setTitle("+", for: .normal)
              middleButton.setTitleColor(ThemeManager.currentTheme().tabBarMiddleButtonTitleColor, for: .normal)
              middleButton.titleLabel?.font = UIFont.systemFont(ofSize: 36.0, weight: .light)
              middleButton.titleEdgeInsets.top = -5
              middleButton.addTarget(self, action: #selector(MainTabBar.handlePressed), for: UIControlEvents.touchUpInside)
              self.addSubview(middleButton)
          }
      }
      if let middleButton = middleButton {
          middleButton.isHidden = false
      }
  }
  
  func hideMiddleButton(){
      if let middleButton = middleButton {
          middleButton.isHidden = true
      }
  }
  
  @objc func handlePressed() {
      middleButtonPressed()
  }
  </code></pre>
  
  <p>}</p>
  
  <p>What could be wrong? I only want the programmatically selected tab to be highlighted.</p>