Skip to content

Instantly share code, notes, and snippets.

@mitsuse
Last active June 26, 2017 07:40
Show Gist options
  • Save mitsuse/375e234da49c2243493a322efba320ae to your computer and use it in GitHub Desktop.
Save mitsuse/375e234da49c2243493a322efba320ae to your computer and use it in GitHub Desktop.
import UIKit
extension UIViewController {
public func present(
_ viewController: UIViewController,
with transitioningDelegate: UIViewControllerTransitioningDelegate,
completion: (() -> Void)? = nil
) {
viewController.transitioningDelegate = transitioningDelegate
viewController.modalPresentationStyle = .custom
self.present(viewController, animated: true) { [transitioningDelegate] in
completion?()
_ = transitioningDelegate
}
}
public func dismiss(with transitioningDelegate: UIViewControllerTransitioningDelegate, completion: (() -> Void)? = nil) {
self.transitioningDelegate = transitioningDelegate
self.dismiss(animated: true) { [transitioningDelegate] in
completion?()
_ = transitioningDelegate
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment