I have a custom segue I'm using "slide" a new view controller into view:
class SegueFromRight: 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.2, delay: 0.0, options: UIViewAnimationOptions.curveEaseInOut, animations: {
dst.view.transform = CGAffineTransform(translationX: 0, y: 0)},
completion: { finished in
src.present(dst, animated: false, completion: nil)
}
)
}
}
And I've set up the segue in my Storyboard.
Now, when I'm done, I want to dismiss this view controller and go back to the preview controller. I am doing so like this:
self.dismiss(animated: true, completion: nil)
However, this uses the default "slide down" animation when it closes. I want to slide the view controller back out to the right (the opposite of my custom segue above). Is there a way I am dismiss a view controller using a custom segue? Or another way to achieve this?