【发布时间】:2014-06-28 19:30:27
【问题描述】:
当导航栏和 UIToolbar 同时在同一个视图上时出现奇怪的问题。刷回vc返回屏幕第一个vc时,导航栏出现奇怪的灰色框:
UIViewController *firstvc = [[UIViewController alloc] init];
firstvc.view.backgroundColor = [UIColor whiteColor];
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 523, 320, 45)];
[firstvc.view addSubview:toolbar];
UIViewController *secondvc = [[UIViewController alloc] init];
secondvc.view.backgroundColor = [UIColor whiteColor];
UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:firstvc];
[nvc pushViewController:secondvc animated:NO];
当我更改工具栏的半透明属性时,一切都按预期工作,但我不喜欢这个解决方案 - UIToolbar 旨在是半透明的。我相信这是在带有 UINavigationController 的视图上使用 UIToolbar 的常用方法。我做错了什么?
更新:UINavigationController 有一个很棒的属性叫toolbar,它在屏幕底部添加了工具栏。然而,问题主要是关于如何一起使用 UIToolbar 和 UINavigationController。例如,我使用屏幕顶部的工具栏开发了一个复杂的视图,其中包括一个自定义 UITextField。当用户在视图上选择某些内容时,会弹出另一个具有本机导航栏的视图控制器。在这种特殊情况下,我遇到了同样的问题,别无选择,只能禁用第一个视图控制器工具栏的半透明属性。
Here the animation that can express my idea.
同样的灰色框。
【问题讨论】:
标签: ios uinavigationcontroller uinavigationbar uitoolbar uiviewanimationtransition