淡入淡出更换 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];
}

posted on 2015-07-23 10:44  yucaijiang  阅读(359)  评论(0编辑  收藏  举报

导航