Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func changeRootViewController(with viewController: UIViewController) {
- guard let oldViewController = self.window?.rootViewController else { return }
- UIView.transition(from: oldViewController.view, to: viewController.view, duration: 0.3, options: [.transitionCrossDissolve, .allowAnimatedContent]) { _ in
- self.window!.rootViewController = viewController
- self.window!.makeKeyAndVisible()
- oldViewController.dismiss(animated: false) {
- oldViewController.view.removeFromSuperview()
- }
- }
- }
- let appDelegate = UIApplication.shared.delegate as? AppDelegate
- appDelegate?.changeRootViewController(with: MyNewViewController())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement