title: Unable to get UIImageView from UITabBar swift
body: <p>I am following <a href="https://github.com/pwax/AnimatedTabBarItemImage/blob/master/AnimatedTabBarItemImage/AnimatedTabBarController.swift" rel="nofollow noreferrer">tutorial</a> to animate tab bar images. The given line of code doesn't work for me</p>
  
  <pre><code>secondItemView.subviews.first as! UIImageView
  </code></pre>
  
  <p>as it gets data of type UITabBarButtonLabel and not UIImageView.
  I added tag value 1 so that I can get UIImageView using tag value
  <a href="https://i.stack.imgur.com/wU6hP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wU6hP.png" alt="enter image description here"></a></p>
  
  <pre><code>secondItemView.viewWithTag(1)
  </code></pre>
  
  <p>returns nil. What is the other way to get UIImageView's reference?</p>
  
  <p>Code</p>
  
  <pre><code>@objc public class MTMainScreenTabsController : UITabBarController {
  var secondItemImageView: UIImageView!
  public override func viewDidLoad() {
      super.viewDidLoad()
      let secondItemView = self.tabBar.subviews[0]
  
  
      print(secondItemView.subviews)
      print(secondItemView.viewWithTag(1))
  
      //self.secondItemImageView = secondItemView.subviews.secon
      var item: UITabBarItem! = self.tabBar.items![0]
  
  
      //self.secondItemImageView = secondItemView.viewWithTag(1) as! UIImageView
  }
  
  public override func viewWillAppear(_ animated: Bool) {
      super.viewWillAppear(animated)
  }
  
  public override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
      if item.tag == 1 {
          self.secondItemImageView.transform = .identity
          UIView.animate(withDuration: 0.7, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 1, options: .curveEaseInOut, animations: {
              () -&gt; Void in
                  //let rotation = CGAffineTransformMakeRotation(CGFloat(M_PI_2))
              let rotation = CGAffineTransform.init(rotationAngle: CGFloat(Double.pi/2))
                  self.secondItemImageView.transform = rotation
          }, completion: nil)
      }
  }
  </code></pre>
  
  <p>}</p>