Created
October 27, 2016 08:44
-
-
Save Daemon-Devarshi/292fdd17e0db6e430bf56beca6961c9a to your computer and use it in GitHub Desktop.
Push animation using custom segue
This file contains 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 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 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