title: swift how make animation flip between two UIViews
body: <p>I'm trying to create an IOS app and flip two views when pressing some buttons. I have found the flip animation but I want the flip to change the content to the new view when it is flipped 90° and not when the animation is completed. This is my function:</p>
  
  <pre><code>func animationFlip(fromView:UIView, toView:UIView, animationTime:Float)
  {
  
      UIView.animateWithDuration(NSTimeInterval(animationTime), animations: {
  
          UIView.setAnimationTransition(UIViewAnimationTransition.FlipFromRight, forView: fromView, cache: true)
  
          },completion:{completion in
              UIView.animateWithDuration(NSTimeInterval(animationTime), animations: { () -&gt; Void in
  
                  fromView.hidden = true;
                  toView.hidden = false;
                  UIView.setAnimationTransition(UIViewAnimationTransition.FlipFromRight, forView: toView, cache: true)
  
  
              })
      })
  }
  </code></pre>
  
  <p>I have found this code which seems to do the trick but it is written in obj-c. How can it be translated to swift?</p>
  
  <pre><code>[UIView transitionFromView:viewToReplace
          toView:replacementView
          duration:1
          options:UIViewAnimationOptionTransitionFlipFromBottom
          completion:nil];
  </code></pre>
  
  <p>Thanks in advance!</p>