同じViewで遷移アニメーションを使う


画面遷移する際のアニメーションを、同じViewで表示を切り替えるタイミングで使用する方法。

@IBAction func Button(sender: AnyObject) {
  if Label.text == "A"  {
    UIView.transitionWithView(self.view, duration: 0.725, options: .TransitionFlipFromLeft, animations: {
      // animation
      self.Label.text = "B"
      }, completion: { (finished: Bool) -> () in
      // completion
    })
  }else{
    UIView.transitionWithView(self.view, duration: 0.725, options: .TransitionFlipFromRight, animations: {
      // animation
      self.Label.text = "A"
      }, completion: { (finished: Bool) -> () in
      // completion
    })
  }
}

参考

UIView transitioning to the same view