SHARE
TWEET

Untitled

a guest Jun 20th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top