【问题标题】:UIToolbar with UINavigationController cases gray box on the navigation bar during animation带有 UINavigationController 的 UIToolbar 在动画期间导航栏上出现灰色框
【发布时间】:2014-06-28 19:30:27
【问题描述】:

当导航栏和 UIToolbar 同时在同一个视图上时出现奇怪的问题。刷回vc返回屏幕第一个vc时,导航栏出现奇怪的灰色框:

Animation

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


    【解决方案1】:

    您不必创建工具栏并添加它。 UIViewController 已经有一个工具栏,您可以在没有您描述的问题的情况下使用它。

    【讨论】:

    • 感谢您的回答。 Toolbar 是一个很棒的属性,但我想知道如何将 UINavigationController 和 UIToolbar 一起使用。屏幕底部的工具栏不仅是 UIToolbar 和 UINavigationController 可以一起使用的情况。
    猜你喜欢
    • 1970-01-01
    • 2016-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多