Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let initialFrame = CGRect(x: xpos, y: -310, width: 300, height: 300)
- let firstView = UIView()
- firstView.backgroundColor = .red
- firstView.frame = initialFrame
- let secondView = UIView()
- secondView.backgroundColor = .white
- secondView.frame = initialFrame
- secondView.isHidden = false
- self.view.addSubview(firstView)
- self.view.addSubview(secondView)
- // Here I try to move the views on screen while fliping them
- UIView.animate(withDuration: 1, delay: 0, options: .curveEaseOut, animations: {
- secondView.center = self.view.center
- firstView.center = self.view.center
- self.flip(firstView: firstView, secondView: secondView)
- }, completion: nil)
- // This function flips the views vertically while it animates the transition from the first to the second view
- fileprivate func flip(firstView: UIView, secondView: UIView) {
- let transitionOptions: UIViewAnimationOptions = [.transitionFlipFromBottom, .showHideTransitionViews]
- UIView.transition(with: firstView, duration: 0.5, options: transitionOptions, animations: {
- firstView.isHidden = true
- })
- UIView.transition(with: secondView, duration: 0.5, options: transitionOptions, animations: {
- secondView.isHidden = false
- })
- }
- UIView.animate(withDuration: 1, delay: 0, options: .curveEaseOut, animations: {
- secondView.center = self.view.center
- firstView.center = self.view.center
- }, completion: {(_) in
- self.flip(firstView: dummyView, secondView: newGroupView)
- })
Add Comment
Please, Sign In to add comment