UINavigationBar 上不显示颜色
我知道这可能是一个非常开放式的问题,但我尝试使用以下方法为我的导航栏设置不同的颜色:
self.navigationController.navigationBar.tintColor = [UIColor greenColor];
由于某种原因,在一个视图控制器中我确实得到了绿色,而在另一个视图控制器中我没有得到绿色颜色。我在 viewdidLoad 中调用它。
有什么东西可以覆盖它吗? (我没有重写drawRect)。
如有必要,很乐意提供任何代码,但这确实让我感到困惑。
谢谢!
I know this may be a pretty open ended question, but I am trying to set a different color to my navigation bar using this:
self.navigationController.navigationBar.tintColor = [UIColor greenColor];
And from some reason in one view controller I do get green color and in another one I am not getting the green color. I am calling this in viewdidLoad.
Is there something that could override that? (I am not overriding drawRect).
Happy to provide any code if necessary, but this really puzzels me.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您正在视图控制器之一中使用第二个
UINavigationController
实例?如果您以模态方式呈现
UIViewController
(UIViewController
方法presentModalViewController:animated:
),则可能会发生这种情况。如果您呈现的
UIViewController
不在同一个“导航堆栈”(由原始UINavigationController
管理)上,则必须对其应用相同的tintColor >UINavigationBar
。Maybe you're using a second
UINavigationController
instance in one of your view controllers?That could happen if you're presenting a
UIViewController
modally (UIViewController
methodpresentModalViewController:animated:
).If you're presenting a
UIViewController
that's not on the same "navigation stack" (managed by the originalUINavigationController
), you would have to apply the same tintColor to itsUINavigationBar
.