- - (void)slideInController:(UINavigationController *)newNavController
- {
- UINavigationController *oldNavController = (UINavigationController *)[AppDelegate rootVC];
- NSMutableArray *newControllers = [NSMutableArray arrayWithArray:newNavController.viewControllers];
- NSLog(@"Newcontrollers: %@", newControllers);
- UIViewController *newTopController = [newControllers lastObject];
- UIViewController *oldTopController = oldNavController.visibleViewController;
- [newControllers removeObject:[newControllers lastObject]];
- [newControllers addObject:oldTopController];
- NSMutableArray *oldControllers = [NSMutableArray arrayWithArray:oldNavController.viewControllers];
- [oldControllers removeObject:[oldControllers lastObject]];
- newNavController.viewControllers = newControllers;
- [AppDelegate setRootVC:newNavController];
- oldNavController.viewControllers = oldControllers;
- [newNavController.visibleViewController.view insertSubview:newTopController.view belowSubview:self.bottomMenu.view];
- newTopController.view.layer.transform = CATransform3DMakeTranslation(0, 600, 0);
- float slideOffset = 0;
- if (!newTopController.wantsFullScreenLayout && oldTopController.wantsFullScreenLayout)
- slideOffset = [[UIApplication sharedApplication] statusBarFrame].size.height;
- if (newTopController.wantsFullScreenLayout && !oldTopController.wantsFullScreenLayout)
- slideOffset = - [[UIApplication sharedApplication] statusBarFrame].size.height;
- [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationCurveEaseOut animations:^{
- newTopController.view.layer.transform = CATransform3DMakeTranslation(0, 0 + slideOffset, 0);
- } completion:^(BOOL finished) {
- [newTopController.view removeFromSuperview];
- newTopController.view.layer.transform = CATransform3DMakeTranslation(0, 0, 0);
- [oldNavController setViewControllers:[oldNavController.viewControllers arrayByAddingObject:oldTopController]];;
- [newControllers removeLastObject];
- self.bottomMenu.view.frame = CGRectMake(0, HEIGHTOF(newTopController.view) - HEIGHTOF(self.bottomMenu.view), WIDTHOF(self.bottomMenu.view), HEIGHTOF(self.bottomMenu.view));
- [newTopController.view addSubview:self.bottomMenu.view];
- newNavController.viewControllers = [newControllers arrayByAddingObject:newTopController];
- }];
- }