Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. func changeRootViewController(with viewController: UIViewController) {
  2. guard let oldViewController = self.window?.rootViewController else { return }
  3. UIView.transition(from: oldViewController.view, to: viewController.view, duration: 0.3, options: [.transitionCrossDissolve, .allowAnimatedContent]) { _ in
  4. self.window!.rootViewController = viewController
  5. self.window!.makeKeyAndVisible()
  6. oldViewController.dismiss(animated: false) {
  7. oldViewController.view.removeFromSuperview()
  8. }
  9. }
  10. }
  11.  
  12. let appDelegate = UIApplication.shared.delegate as? AppDelegate
  13. appDelegate?.changeRootViewController(with: MyNewViewController())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement