title: Fill UIImageView with other color animated
body: <p>I'm having a imageview and I want that imageview to animate with a color. So my image is first a green one and then I want to animate it to a orange one.</p>
  
  <p>This is my code:</p>
  
  <pre><code>class TestView: UIView {
  
      func startAnimate(){
  
          let size:CGSize = self.bounds.size
  
          let layer = UIImageView(image: UIImage(named: "LaunchIcon"))
          layer.frame = self.bounds
  
          let initialRect:CGRect = CGRect.init(x: 0, y: size.height, width: size.width, height: 0)
          let finalRect:CGRect = CGRect.init(x: 0, y: size.height, width: size.width, height: size.height)
  
          let sublayer = CALayer()
          sublayer.frame = initialRect
          sublayer.backgroundColor = UIColor.orange.cgColor
          sublayer.opacity = 0.5
  
  
          let mask:CAShapeLayer = CAShapeLayer()
          mask.frame = self.bounds
          mask.path = UIBezierPath(rect: self.bounds).cgPath
          mask.fillColor = UIColor.black.cgColor
  
          layer.layer.addSublayer(sublayer)
          layer.layer.mask = mask
  
          self.layer.addSublayer(layer.layer)
  
          let boundsAnim:CABasicAnimation  = CABasicAnimation(keyPath: "bounds")
          boundsAnim.toValue = NSValue.init(cgRect:finalRect)
  
          let animationGroup = CAAnimationGroup()
          animationGroup.animations = [boundsAnim]
          animationGroup.isRemovedOnCompletion = false
          animationGroup.duration = 2
          animationGroup.fillMode = kCAFillModeForwards
  
          sublayer.add(animationGroup, forKey: nil)
      }
  }
  </code></pre>
  
  <p>My result:</p>
  
  <p><a href="https://i.stack.imgur.com/S4ysQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/S4ysQ.png" alt="enter image description here"></a></p>
  
  <p>The first problem is that the orange is taking the whole frame and not just my image. The second problem is that it doesn't fill to the top.</p>