当我更改关键窗口时,rootViewController(s)没有接收到的视图将/确实出现/消失。
SplashViewController *screenLockViewController = [[SplashViewController alloc] initWithNibName:@"SplashViewController" bundle:nil];
[self.splashWindow.rootViewController presentViewController:splashViewController animated:NO completion:nil];
[self.splashWindow makeKeyWindow];
__weak typeof(self) welf = self;
[UIView transitionWithView:self.window
duration:0.25
options:UIViewAnimationOptionTransitionNone
animations:^{
welf.window.alpha = 0.0f;
} completion:^(BOOL finished) {
[welf.window setHidden:YES];
}];
更新 手动调用 - beginAppearanceTransition:animated:和 - endAppearanceTransition 来自https://stackoverflow.com/a/25033107/2287841
SplashViewController *screenLockViewController = [[SplashViewController alloc] initWithNibName:@"SplashViewController" bundle:nil];
[self.splashWindow.rootViewController presentViewController:splashViewController animated:NO completion:nil];
[self.window.rootViewController beginAppearanceTransition:NO animated:shouldAnimate]; // call view will disappear
[self.splashWindow makeKeyWindow];
__weak typeof(self) welf = self;
[UIView transitionWithView:self.window
duration:0.25
options:UIViewAnimationOptionTransitionNone
animations:^{
welf.window.alpha = 0.0f;
[welf.window.rootViewController endAppearanceTransition]; // call view did disappear
} completion:^(BOOL finished) {
[welf.window setHidden:YES];
}];