Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- class SpecialEffectSegue: UIStoryboardSegue {
- override func perform() {
- let firstVCView = self.source.view as UIView!
- let secondVCView = self.destination.view as UIView!
- let intermediateView = UIView()
- intermediateView.backgroundColor = UIColor.red
- // Get the screen width and height.
- let screenWidth = UIScreen.main.bounds.size.width
- let screenHeight = UIScreen.main.bounds.size.height
- // Specify the initial position of the destination view.
- secondVCView?.frame = CGRect(x: 0.0, y: screenHeight, width: screenWidth, height: screenHeight)
- intermediateView.frame = CGRect(x: 0.0, y: screenHeight, width: screenWidth, height: screenHeight)
- // Access the app's key window and insert the destination view above the current (source) one.
- let window = UIApplication.shared.keyWindow
- window?.insertSubview(intermediateView, aboveSubview: firstVCView!)
- window?.insertSubview(secondVCView!, aboveSubview: secondVCView!)
- UIView.animate(withDuration: 0.4, animations: { () -> Void in
- firstVCView?.frame = ((firstVCView?.frame)?.offsetBy(dx: 0.0, dy: -screenHeight))!
- intermediateView.frame = (intermediateView.frame.offsetBy(dx: 0.0, dy: -screenHeight))
- }) { (Finished) -> Void in
- UIView.animate(withDuration: 0.4, animations: { () -> Void in
- secondVCView?.frame = (secondVCView?.frame.offsetBy(dx: 0.0, dy: -screenHeight))!
- }) { (Finished) -> Void in
- self.source.present(self.destination, animated: false, completion: {
- intermediateView.removeFromSuperview()
- })
- }
- }
- }
- }
- let firstVCView = self.source.view as UIView!
- let secondVCView = self.destination.view as UIView!
- let intermediateView = UIView()
- intermediateView.backgroundColor = UIColor.red
- let screenWidth = UIScreen.main.bounds.size.width
- let screenHeight = UIScreen.main.bounds.size.height
- // Specify the initial position of the destination view.
- secondVCView?.frame = CGRect(x: 0.0, y: screenHeight, width: screenWidth, height: screenHeight)
- intermediateView.frame = CGRect(x: 0.0, y: screenHeight, width: screenWidth, height: screenHeight)
- let window = UIApplication.shared.keyWindow
- window?.insertSubview(intermediateView, aboveSubview: firstVCView!)
- window?.insertSubview(secondVCView!, aboveSubview: secondVCView!)
- UIView.animate(withDuration: 0.4, animations: { () -> Void in
- firstVCView?.frame = ((firstVCView?.frame)?.offsetBy(dx: 0.0, dy: -screenHeight))!
- intermediateView.frame = (intermediateView.frame.offsetBy(dx: 0.0, dy: -screenHeight))
- }) { (Finished) -> Void in
- UIView.animate(withDuration: 0.4, animations: { () -> Void in
- secondVCView?.frame = (secondVCView?.frame.offsetBy(dx: 0.0, dy: -screenHeight))!
- }) { (Finished) -> Void in
- self.source.present(self.destination, animated: false, completion: {
- intermediateView.removeFromSuperview()
- })
- }
- }
- self.source.navigationController?.pushViewController(destination, animated: false)
Add Comment
Please, Sign In to add comment