Skip to content

Instantly share code, notes, and snippets.

@gimenete
Last active July 31, 2020 16:20
Show Gist options
  • Save gimenete/53704124583b5df3b407 to your computer and use it in GitHub Desktop.
Save gimenete/53704124583b5df3b407 to your computer and use it in GitHub Desktop.
Animated rootViewController transition
// 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];
}];
}
@Bodacious
Copy link

Nice!

@AakifNadeem
Copy link

AakifNadeem commented Jul 31, 2020

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