title: How to remove delay on start and end of animateKeyframes animation - Swift UIKit
body: <p>Is there a way to remove the delay on start and end of the animateKeyframes animation?</p>
  <p>As you can see there is a slight delay before the animation starts; after tapping on the <code>Animate</code> button and also at the end of the animation. What I would like to be able to do is start the animation as soon as the <code>Animate</code> button is tapped since this is meant to provide feedback to the user.</p>
  <p>Is this the normal behavior when using <code>animateKeyframes</code> animations with the <code>calculationModeCubic</code>?  Is there a way to make the animation starts as soon as the button is tapped?</p>
  <p><a href="https://i.stack.imgur.com/cIWho.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cIWho.gif" alt="enter image description here" /></a></p>
  <p>Sorry about the misspelling error (Aniamate).</p>
  <h2>Here is the code:</h2>
  <pre><code>@IBAction func startAnimation(_ sender: Any) {
      addMyView()
      
      UIView.animateKeyframes(withDuration: 3.0, delay: 0.0, options: [.calculationModeCubic], animations: {
          UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 0.2, animations: {
              self.myView!.center =  CGPoint(x: self.pointA.center.x, y: self.pointA.center.y)
          })
          UIView.addKeyframe(withRelativeStartTime: 0.2, relativeDuration: 0.2, animations: {
              self.myView!.center =  CGPoint(x: self.pointB.center.x + 55, y: self.pointB.center.y - 5 )
              self.myView!.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
          })
          
          UIView.addKeyframe(withRelativeStartTime: 0.4, relativeDuration: 0.2, animations: {
              self.myView!.center =  CGPoint(x: self.pointB.center.x, y: self.pointB.center.y)
              self.myView!.transform = CGAffineTransform(scaleX: 0.5, y: 0.5)
          })
      }, completion: { _ in
          self.myView?.removeFromSuperview()
      })
  }
  
  func addMyView(){
      myView = UIView(frame: CGRect(x: pointA.center.x - 25, y: pointA.center.y - 25, width: 50, height: 50))
      myView?.backgroundColor = .blue
      myView?.layer.cornerRadius = myView!.frame.height / 2
      view.addSubview(myView!)
  }
  </code></pre>