Thursday, 12 March 2015

Change root view controller animation

- (void)changeRootViewController:(UIViewController*)viewController {

    UIWindow *window = [[UIApplication sharedApplication] keyWindow];
    if (!window.rootViewController) {
        window.rootViewController = viewController;
        return;
    }

    UIView *snapShot = [window snapshotViewAfterScreenUpdates:YES];
    [viewController.view addSubview:snapShot];
    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];
    }];
}
Reference

No comments:

Post a Comment