3

I need to switch between two subviews, for that I am using flip animation, but it flips whole screen not subview. Here is the code I used to flip:

UIView.transitionFromView(frontView, toView: backView, duration: 1, options: UIViewAnimationOptions.TransitionFlipFromRight | UIViewAnimationOptions.ShowHideTransitionViews, completion: nil)

I have created frontView and backView in StoryBoard, and backView hidden initially.

Please help me too flip only the subviews.

AMAN77
  • 6,218
  • 9
  • 45
  • 60
naresh
  • 627
  • 1
  • 7
  • 28

2 Answers2

4

finally i got fix for this, we need to add frontView and backView to another View(container) not for self.view, then container will flip.

naresh
  • 627
  • 1
  • 7
  • 28
4

This question is old, but it can help someone. If you want to flip your self.view use it:

Swift 2

UIView.transitionWithView(self.view, duration: 0.8, options: UIViewAnimationOptions.TransitionFlipFromRight | UIViewAnimationOptions.ShowHideTransitionViews, animations: {
    self.view.addSubview(newView)
}, completion: { finished in
    // HERE you can remove your old view
    oldView.removeFromSuperview()
})

Swift 3, 4, 5

UIView.transition(with: self.view, duration: 0.8, options: [UIView.AnimationOptions.transitionFlipFromRight, UIView.AnimationOptions.showHideTransitionViews], animations: {
    self.view.addSubview(newView)
}, completion: { finished in
    // HERE you can remove your old view
    oldView.removeFromSuperview()
})
Seb Jachec
  • 3,003
  • 2
  • 30
  • 56
Elto
  • 420
  • 3
  • 11