Search code examples
iphoneiosuinavigationcontrollerpushviewcontrollercatransition

CATransition white flash in background?


I'm trying to make a pushViewController slide in from the left, not the right, as follows:

Page14Controller * controller = [[Page14Controller alloc] initWithNibName:@"Page14Controller" bundle:nil];

CATransition* transition = [CATransition animation];
transition.duration = 0.3;
transition.type = kCATransitionPush;
//                transition.type = kCATransitionMoveIn; 
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
//kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
transition.subtype = kCATransitionFromLeft; 
//kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
[self.navigationController.view.layer addAnimation:transition forKey:nil];

[self.navigationController pushViewController:controller animated:NO];

When I do this, the current controller fades to white, which looks terrible. Why does this happen? I've tried setting the background of the current view's alpha to 0.


Solution

  • I figured out what was apparently causing the white flash: it was the background of the main window. Setting this to alpha=0 helps the white effect. It appears that kCATransitionPush actually fades the view being pushed off screen, and obviously if what is under that is green, then it'll fade to green. It'd be nice if it didn't also fade, but that's a different question.