Question

I have a UINavigationController whose UIView slides in from the bottom of the screen when the user presses a button.

Immediately after I set the view's "hidden" property to NO, though, the UINavigationController's view sometimes appears fully in place for one frame, as if the animation was finished already.

This is the code that shows/hides the view:

- (void)showGUI: (bool)show
{
 CATransition *transition = [CATransition animation];
 transition.duration = 0.5;
 transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

 if (!show)
 {
  transition.type = kCATransitionReveal;
  transition.subtype = kCATransitionFromBottom;
 }
 else 
 {
  transition.type = kCATransitionMoveIn;
  transition.subtype = kCATransitionFromTop;
 }

 [navController.view.superview.layer addAnimation:transition forKey:nil];

 navController.view.hidden = !show;
}
Was it helpful?

Solution

CATransition animations are applied when layers are added/removed from the layer you add the animation to. If toggling the hidden property doesn't work, then try removing the view instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top