iOS 淡入淡出转换rootViewController

登陆之后转换rootViewController

// 淡入淡出改变rootViewController

- (void)restoreRootViewController:(UIViewController *)rootViewController {

    typedef void (^Animation)(void);

    UIWindow* window = self.window;

    

    rootViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

    Animation animation = ^{

        BOOL oldState = [UIView areAnimationsEnabled];

        [UIView setAnimationsEnabled:NO];

        window.rootViewController = rootViewController;

        [UIView setAnimationsEnabled:oldState];

    };

    

    [UIView transitionWithView:window

                      duration:0.5f

                       options:UIViewAnimationOptionTransitionCrossDissolve

                    animations:animation

                    completion:nil];

}

详情请看这儿

你可能感兴趣的:(ios)