我使用以下代码将导航控制器从一个视图控制器弹出到第二个。
-(void)viewProfile :(UIButton *)sender{
NSMutableArray *allViewControllers = [NSMutableArray arrayWithArray: self.navigationController.viewControllers];
ProfileViewController *newVC = [[ProfileViewController alloc] initWithNibName:@"ProfileViewController" bundle:nil];
[allViewControllers insertObject:newVC atIndex:0];
self.navigationController.viewControllers = allViewControllers;
CATransition* transition = [CATransition animation];
transition.duration = 0.2f;
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.navigationController.view.layer addAnimation:transition
forKey:kCATransition];
[self.navigationController popViewControllerAnimated:NO];
}
代码效果很好。一个缺陷是视图控制器到来的转换或ProfileViewController显示为黑色。然后在动画过程中它会亮到默认值,同时调用此功能的视图控制器变为黑色。
如何防止这种阴影,并让视图在整个过渡过程中始终具有默认颜色?