我目前正在开发我的第一个 iOS 应用程序,并且很长一段时间以来一直在摆弄以下问题:
我正在使用带有导航和工具栏的导航 Controller ,它们最初都是隐藏的。通过点击屏幕,您可以切换栏。
现在我需要只用阴影线勾勒条形,否则在背景中是白色的(就像我的 Root View 的背景一样),黑色字体。我通过设置来实现
self.navigationController.toolbar.tintColor = [UIColor whiteColor];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
并稍微调整 appdelegate 中字体的外观:
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:0 green:0 blue:0 alpha:1.0],UITextAttributeTextColor,
[UIColor colorWithRed:255 green:255 blue:255 alpha:0],UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, -1)],UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"Helvetica" size:0.0],UITextAttributeFont,
nil]]
到目前为止一切正常。不过问题来了:
我希望导航和工具栏在切换时都具有动画效果(这种平滑的滑入/滑出)没有 调整 Root View 的大小。就像现在设置的那样,这适用于工具栏,但导航栏一直拒绝这样做。
我尝试将导航栏设置为半透明:
- Root View 没有调整大小,但导航栏也没有动画,它只是弹出
不将其设置为半透明:
- 导航栏滑入但 Root View 被推下
我还尝试将导航栏的 autoresizingMask 设置为 UIViewAutoresizingNone 并尝试在界面构建器中设置我的 View 的 Spring 和支柱,但没有任何帮助。
提前感谢您的帮助。
最佳答案
您可以尝试使用 setCenter:
和 setFrame:
UINavigationBar
上的方法执行您的“幻灯片”。
关于ios - 无需调整内容 View 大小的动画导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13935824/