可能这种类型的问题发生在许多开发者身上,我也试图在Google上找到,但是没有运气来解决我的问题.
在我的应用程序中,rootViewController动态地设置在窗口上,我的意思是用户可以在运行时应用程序更改root视图.所以我首先从UIWindow中删除当前的rootViewController,然后在UIWindow上设置新的rootViewController,并使用特定的动画.
这个动画由CATransition与transition.type = kCATransitionPush ;.
我的应用程序工作非常好,除了新的rootViewController的动画.如上所述,我使用kCATransitionPush与CATransition
编辑:
以下是我的代码:
- -(void) changeRootViewController
- {
- for(UIView *subViews in self.window.rootViewController.view.subviews)
- [subViews removeFromSuperview];
- [self.window.rootViewController.view removeFromSuperview];
- self.window.rootViewController.view = nil;
- [self.window.rootViewController removeFromParentViewController];
- MainRootViewController *mainRootVC = [[MainRootViewController alloc] init];
- CATransition *animation = [CATransition animation];
- [animation setDuration:0.4];
- [animation setType:kCATransitionPush];
- [animation setSubtype:kCATransitionFromRight];
- animation.fillMode = kCAFillModeForwards;
- [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];
- self.window.rootViewController = mainRootVC;
- [[self.window layer] addAnimation:animation forKey:nil];
- }
我也试图设置UIWindow背景的clearColor和whiteColor.但不工作
我的问题是:当动画处理(从右到左)时,我变得黑影.所以任何人都可以帮我隐藏这个黑影?请给你金色的建议.
谢谢.