title: iOS stop animateWithDuration before completion
body: <p>I have a CollectionView and I want to create an animation inside the CollectionViewCell selected by the user. I chose to use animateKeyframesWithDuration because I want to create a custom animation step by step. My code looks like this:</p>
  
  <pre><code>func animate() {
      UIView.animateKeyframesWithDuration(1.0, delay: 0.0, options: .AllowUserInteraction, animations: { () -&gt; Void in
          UIView.addKeyframeWithRelativeStartTime(0.0, relativeDuration: 0.5, animations: { () -&gt; Void in
              //  First step
          })
          UIView.addKeyframeWithRelativeStartTime(0.5, relativeDuration: 0.5, animations: { () -&gt; Void in
              //  Second step
          })
          }) { (finished: Bool) -&gt; Void in
              if self.shouldStopAnimating {
                  self.loadingView.layer.removeAllAnimations()
              } else {
                  self.animate()
              }
          }
  }
  </code></pre>
  
  <p>This is executed inside the custom CollectionViewCell when it is selected.
  The problem is that I want to force stop the animation immediately at some certain point. But when I do that, the animation doesn't fully stop, it just moves the remaining animation on a different cell (probably the last reused cell?)</p>
  
  <p>I can't understand why this is happening. I have tried different approaches but none of them successfully stop the animation before normally entering the completion block </p>
  
  <p>Does anyone have any idea about this?</p>