Skip to content

Instantly share code, notes, and snippets.

@trilliwon
Created May 24, 2017 04:40
Show Gist options
  • Save trilliwon/7d0e4495f3e27902864c6f627fbae1f1 to your computer and use it in GitHub Desktop.
Save trilliwon/7d0e4495f3e27902864c6f627fbae1f1 to your computer and use it in GitHub Desktop.
import UIKit
class FadeInOut: UIStoryboardSegue {
override func perform() {
let sourceView: UIView = self.source.view as UIView!
let destinationView: UIView = self.destination.view as UIView!
sourceView.alpha = 1.0
destinationView.alpha = 0.0
let window = UIApplication.shared.keyWindow
window?.insertSubview(destinationView, aboveSubview: sourceView)
UIView.animate(withDuration: 0.2, animations: { () -> Void in
sourceView.alpha = 0.0
destinationView.alpha = 1.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