Refactored

This commit is contained in:
Alexey Gerasimov 2018-03-30 19:27:30 +03:00
parent 11cce2d920
commit 828d63838c
1 changed files with 7 additions and 5 deletions

View File

@ -32,12 +32,14 @@ public extension UIWindow {
/// Method changes root controller in window.
///
/// - Parameter controller: New root controller.
func changeRootController(controller: UIViewController) {
animateRootViewControllerChanging(controller: controller)
/// - Parameter animated: Indicates whether to use animation or not.
func changeRootController(controller: UIViewController, animated: Bool = true) {
if animated {
animateRootViewControllerChanging(controller: controller)
}
let previousRoot = rootViewController
previousRoot?.dismiss(animated: false) {
previousRoot?.view.removeFromSuperview()
rootViewController?.dismiss(animated: false) { [weak self] in
self?.rootViewController?.view.removeFromSuperview()
}
rootViewController = controller