Skip to content

Instantly share code, notes, and snippets.

@trilliwon
Created May 24, 2017 04:39
Show Gist options
  • Save trilliwon/efd45236e0ce06922e1591c8c8144e3f to your computer and use it in GitHub Desktop.
Save trilliwon/efd45236e0ce06922e1591c8c8144e3f to your computer and use it in GitHub Desktop.
import UIKit
class ToLeftSegue: UIStoryboardSegue {
override func perform() {
let sourceView = self.source.view as UIView!
let destinationView = self.destination.view as UIView!
let screenWidth = UIScreen.main.bounds.size.width
let screenHeight = UIScreen.main.bounds.size.height
destinationView?.frame = CGRect(x: -screenWidth, y: 0.0, width: screenWidth, height: screenHeight)
let window = UIApplication.shared.keyWindow
window?.insertSubview(destinationView!, aboveSubview: sourceView!)
UIView.animate(withDuration: 0.2, animations: { () -> Void in
sourceView?.frame = (sourceView?.frame.offsetBy(dx: screenWidth, dy: 0.0))!
destinationView?.frame = (destinationView?.frame.offsetBy(dx: screenWidth, dy: 0.0))!
}, completion: { (_) -> Void in
self.source.present(self.destination as UIViewController, animated: false, completion: nil)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment