Skip to content

Instantly share code, notes, and snippets.

@jugutier
Created October 17, 2017 23:07
Show Gist options
  • Save jugutier/292f74271149b08ba8c4e9ad1bdd77d3 to your computer and use it in GitHub Desktop.
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
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