Created
October 17, 2017 23:07
-
-
Save jugutier/292f74271149b08ba8c4e9ad1bdd77d3 to your computer and use it in GitHub Desktop.
Custom transition to push a VC in a navigation controller from left instead of right (the usual) More info here: https://stackoverflow.com/a/35574014/1904232
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 SegueFromLeft: UIStoryboardSegue { | |
override func perform() { | |
let src = self.source | |
let dst = self.destination | |
src.view.superview?.insertSubview(dst.view, aboveSubview: src.view) | |
dst.view.transform = CGAffineTransform(translationX: -src.view.frame.size.width, y: 0) | |
UIView.animate(withDuration: 0.25, | |
delay: 0.0, | |
options: .curveEaseInOut, | |
animations: { | |
dst.view.transform = CGAffineTransform(translationX: 0, y: 0) | |
}, | |
completion: { finished in | |
src.present(dst, animated: false, completion: nil) | |
} | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment