title: select tabbar item programmatically and show the indicator image
body: <p>I am using UITabBar, not UITabBarController. Whenever user clicks on any tab, I am able to see the underlined image.</p>
  
  <pre><code>public override func viewDidLoad() {
      super.viewDidLoad()
      UITabBar.appearance().selectionIndicatorImage = getImageWithColorPosition(color: UIColor.darkGray, size: CGSize(width:presenterView.frame.size.width/2, height:49), lineSize: CGSize(width:presenterView.frame.size.width/2, height:2))
  }
  </code></pre>
  
  <p>//getImageWithColorPosition is for adding underlined image below UITabBarItem</p>
  
  <pre><code>func getImageWithColorPosition(color: UIColor, size: CGSize, lineSize: CGSize) -&gt; UIImage {
      let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
      let rectLine = CGRect(x: 0, y: size.height-lineSize.height, width: lineSize.width, height: lineSize.height)
      UIGraphicsBeginImageContextWithOptions(size, false, 0)
      UIColor.clear.setFill()
      UIRectFill(rect)
      color.setFill()
      UIRectFill(rectLine)
      let image = UIGraphicsGetImageFromCurrentImageContext()!
      UIGraphicsEndImageContext()
      return image
  }
  
  public override func viewWillAppear(_ animated: Bool) {
      super.viewWillAppear(animated)
      openItem1()
  }
  
  public func  tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
      if (item.tag == 0) {
          openItem1()
      } else {
          openItem2()
      }
  }
  </code></pre>
  
  <p>However, when user clicks on any of the tab items then only underlined image is displayed. I want to select a default tab when user lands on the screen for the first time. As I am doing it programmatically, the underline image doesn't show up. I read couple of stack overflow posts which say that selection on UITabBar can not be triggered programmatically.</p>
  
  <p>Is there any other way to go about it?</p>