Last active
July 31, 2020 16:20
-
-
Save gimenete/53704124583b5df3b407 to your computer and use it in GitHub Desktop.
Animated rootViewController transition
This file contains 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
// put this in your AppDelegate | |
- (void)changeRootViewController:(UIViewController*)viewController { | |
if (!self.window.rootViewController) { | |
self.window.rootViewController = viewController; | |
return; | |
} | |
UIView *snapShot = [self.window snapshotViewAfterScreenUpdates:YES]; | |
[viewController.view addSubview:snapShot]; | |
self.window.rootViewController = viewController; | |
[UIView animateWithDuration:0.3 animations:^{ | |
snapShot.layer.opacity = 0; | |
snapShot.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5); | |
} completion:^(BOOL finished) { | |
[snapShot removeFromSuperview]; | |
}]; | |
} |
Try this out!
let sb = UIStoryboard(name: "Main", bundle: nil)
let VC = sb.instantiateViewController(withIdentifier: "LoginViewController") as! LoginViewController
let navRootView = UINavigationController(rootViewController: VC)
self.present(navRootView, animated: true, completion: nil)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice!