Guest User

Untitled

a guest
Mar 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. import UIKit
  2.  
  3. class SpecialEffectSegue: UIStoryboardSegue {
  4. override func perform() {
  5.  
  6. let firstVCView = self.source.view as UIView!
  7. let secondVCView = self.destination.view as UIView!
  8. let intermediateView = UIView()
  9. intermediateView.backgroundColor = UIColor.red
  10.  
  11. // Get the screen width and height.
  12. let screenWidth = UIScreen.main.bounds.size.width
  13. let screenHeight = UIScreen.main.bounds.size.height
  14.  
  15. // Specify the initial position of the destination view.
  16. secondVCView?.frame = CGRect(x: 0.0, y: screenHeight, width: screenWidth, height: screenHeight)
  17. intermediateView.frame = CGRect(x: 0.0, y: screenHeight, width: screenWidth, height: screenHeight)
  18.  
  19. // Access the app's key window and insert the destination view above the current (source) one.
  20. let window = UIApplication.shared.keyWindow
  21. window?.insertSubview(intermediateView, aboveSubview: firstVCView!)
  22. window?.insertSubview(secondVCView!, aboveSubview: secondVCView!)
  23.  
  24. UIView.animate(withDuration: 0.4, animations: { () -> Void in
  25. firstVCView?.frame = ((firstVCView?.frame)?.offsetBy(dx: 0.0, dy: -screenHeight))!
  26. intermediateView.frame = (intermediateView.frame.offsetBy(dx: 0.0, dy: -screenHeight))
  27. }) { (Finished) -> Void in
  28. UIView.animate(withDuration: 0.4, animations: { () -> Void in
  29. secondVCView?.frame = (secondVCView?.frame.offsetBy(dx: 0.0, dy: -screenHeight))!
  30. }) { (Finished) -> Void in
  31. self.source.present(self.destination, animated: false, completion: {
  32. intermediateView.removeFromSuperview()
  33. })
  34. }
  35. }
  36. }
  37. }
  38.  
  39. let firstVCView = self.source.view as UIView!
  40. let secondVCView = self.destination.view as UIView!
  41.  
  42. let intermediateView = UIView()
  43. intermediateView.backgroundColor = UIColor.red
  44.  
  45. let screenWidth = UIScreen.main.bounds.size.width
  46. let screenHeight = UIScreen.main.bounds.size.height
  47.  
  48. // Specify the initial position of the destination view.
  49. secondVCView?.frame = CGRect(x: 0.0, y: screenHeight, width: screenWidth, height: screenHeight)
  50. intermediateView.frame = CGRect(x: 0.0, y: screenHeight, width: screenWidth, height: screenHeight)
  51.  
  52. let window = UIApplication.shared.keyWindow
  53.  
  54. window?.insertSubview(intermediateView, aboveSubview: firstVCView!)
  55. window?.insertSubview(secondVCView!, aboveSubview: secondVCView!)
  56.  
  57. UIView.animate(withDuration: 0.4, animations: { () -> Void in
  58. firstVCView?.frame = ((firstVCView?.frame)?.offsetBy(dx: 0.0, dy: -screenHeight))!
  59. intermediateView.frame = (intermediateView.frame.offsetBy(dx: 0.0, dy: -screenHeight))
  60. }) { (Finished) -> Void in
  61. UIView.animate(withDuration: 0.4, animations: { () -> Void in
  62. secondVCView?.frame = (secondVCView?.frame.offsetBy(dx: 0.0, dy: -screenHeight))!
  63. }) { (Finished) -> Void in
  64. self.source.present(self.destination, animated: false, completion: {
  65. intermediateView.removeFromSuperview()
  66. })
  67. }
  68. }
  69.  
  70. self.source.navigationController?.pushViewController(destination, animated: false)
Add Comment
Please, Sign In to add comment