I'm trying to animate a transition from a UINavigationController
to a UISplitViewController
, but the split view controller doesn't draw correctly until the animation is finished. The navigation bars are transparent and their titles are positioned wrong. When the animation finishes, they jump to the "correct" location. I'm using
-transitionFromViewController:toViewController:duration:options:animations:completion
The UISplitViewController
has UINavigationController
s for both its master and detail. As it is transitioning in, the navigation bar is dark gray and the title is offset too high. Once the animation finishes, the bar quickly changes color to light gray and the title jumps into the correct place. Here's some example code:
// Master and its nav
UIViewController *master = [[UIViewController alloc] init];
master.title = @"master";
UINavigationController *masterNav = [[UINavigationController alloc] initWithRootViewController:master];
masterNav.toolbarHidden = NO;
// Detail and its nav
UIViewController *detail = [[UIViewController alloc] init];
detail.title = @"detail";
UINavigationController *detailNav = [[UINavigationController alloc] initWithRootViewController:detail];
// Split
UISplitViewController *splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = @[ masterNav, detailNav ];
// Now transition
UIViewController *from = [self.childViewControllers lastObject];
[self addChildViewController:splitViewController];
NSTimeInterval duration = 1.0;
UIViewAnimationOptions options = UIViewAnimationOptionTransitionCrossDissolve;
[self transitionFromViewController:from
toViewController:splitViewController
duration:duration
options:options
animations:^{}
completion:^(BOOL finished) {
[splitViewController didMoveToParentViewController:self];
}];