-
-
Save dropocol/f095f7665d76433b13d32df9d3e66808 to your computer and use it in GitHub Desktop.
Push animation using custom segue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol Pop { | |
| func moveBackToParentViewController(currentViewController: UIViewController) | |
| } | |
| extension Pop { | |
| func moveBackToParentViewController(currentViewController: UIViewController) { | |
| let transition = CATransition() | |
| transition.duration = 0.5 | |
| transition.type = kCATransitionMoveIn | |
| transition.subtype = kCATransitionFromLeft | |
| currentViewController.view.window!.layer.add(transition, forKey: kCATransition) | |
| currentViewController.dismiss(animated: true, completion: nil) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| class Push: UIStoryboardSegue { | |
| override func perform() { | |
| let transition = CATransition() | |
| transition.duration = 0.5 | |
| transition.type = kCATransitionPush | |
| transition.subtype = kCATransitionFromRight | |
| source.view.window!.layer.add(transition, forKey: kCATransition) | |
| source.present(destination, animated: false, completion: nil) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PushedViewController: UIViewController, Pop { | |
| @IBAction func backAction(_ sender: AnyObject) { | |
| moveBackToParentViewController(currentViewController: self) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment