如何在不隐藏标签栏的情况下用自下而上的动画呈现UIViewController



所以,我有一个UITabbarControllerUINavigationController在它。按下按钮后,我想引入另一个UINavigationController,像使用presentModalViewController:animated:时一样使其动画,但我不希望它隐藏标签栏。

有什么在UIKit(3.1.3及以后),我可以使用这个或我将不得不做动画自己吗?

只是测试代码,也许你需要设置navigationControllerproperty,如果你需要做pushViewController:animated:

UIViewController * aViewController = [[UIViewController alloc] init];
[aViewController.view setFrame:self.view.frame];
[aViewController.view setBackgroundColor:[UIColor redColor]];
UINavigationController * navigationController = [[UINavigationController alloc] initWithRootViewController:aViewController];
[aViewController release];
[navigationController.view setFrame:CGRectMake(0.0f, 480.0f, 320.0f, 480.0f)];
[self.navigationController.view addSubview:navigationController.view];
[UIView animateWithDuration:0.3f
                      delay:0.0f
                    options:UIViewAnimationOptionCurveLinear
                 animations:^{
                     [navigationController.view setFrame:CGRectMake(0.0f, 0.0f, 320.0f, 480.0f)];
                 }
                 completion:nil];
[navigationController release];

默认情况下,从下向上呈现内容的唯一方法是presentModalViewController。你实际上可以覆盖你的navigationController的动画,但这不是你可以通过调用一个不同的方法来实现的,你必须创建你自己的,并处理动画。

另一种可能的欺骗方法是在你正在模态呈现的视图中重新加载你的选项栏,但这可能会变得很混乱。

最新更新