title: How to cancel previous animation when a new one is triggered?
body: <p>I am writing a camera app, and have trouble with showing the focus square when user tap on the screen.</p>
  
  <p>My code is (in swift):</p>
  
  <pre><code>self.focusView.center = sender.locationInView(self.cameraWrapper)
  self.focusView.transform = CGAffineTransformMakeScale(2, 2)
  self.focusView.hidden = false
  
  UIView.animateWithDuration(0.5, animations: { [unowned self] () -&gt; Void in
      self.focusView.transform = CGAffineTransformIdentity
  }, completion: { (finished) -&gt; Void in
      UIView.animateWithDuration(0.5, delay: 1.0, options: nil, animations: { () -&gt; Void in
          self.focusView.alpha = 0.0
      }, completion: { (finished) -&gt; Void in
              self.focusView.hidden = true
              self.focusView.alpha = 1.0
      })
  })
  </code></pre>
  
  <p>However, if use tap the screen consecutively when the previous animation does not finish, the old and new animation will mix up and the focus view will behave strangely, for example it will disappear very quick.</p>
  
  <p>Could anyone tell me how to cancel previous animation, especially the previous completion block?</p>