Created
June 27, 2017 12:30
-
-
Save starhoshi/4de7244849d1e3f9b1dd29ccc60c56af to your computer and use it in GitHub Desktop.
rootViewController を別の ViewController に入れ替える [Swift3]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIWindow { | |
func changeRootViewController(new viewController: UIViewController) { | |
UIView.transition( | |
with: UIApplication.shared.keyWindow!, | |
duration: 0.5, | |
options: .transitionCrossDissolve, | |
animations: { | |
UIApplication.shared.keyWindow?.rootViewController = viewController | |
}, | |
completion: nil | |
) | |
} | |
} | |
UIWindow().changeRootViewController(new: UIViewController()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment