更改 UINavigationBar 中的文本颜色
我以前见过这个问题,并找到了如何以简单的方式做到这一点的答案。但是......当我转到推送到视图堆栈上的后续视图时,手动设置 titleView 不起作用。 titleView 视图被推到右侧,而后退按钮及其文本占据 UI 的左半部分。
有没有标准的方法来做到这一点?我注意到 Gowalla 应用程序显然做得很好。我尝试了多种方法,包括类别、子类等,但没有任何运气。
I've seen this question asked around before, and found an answer for how to do this in a simple view. But... when I go to a subsequent view pushed onto the view stack, manually setting the titleView doesn't work out. The titleView view gets pushed off to the right while the back button and its text take over the left half of the UI.
Is there a standard way to do this? I've noticed the Gowalla app apparently does it quite well. I've tried a multitude of approaches including categories, subclasses, etc and haven't had any luck.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每个
UIViewController
都有它自己的navigationItem
,它(可能)有一个titleView
。当您在导航控件中推送和弹出视图控制器时,navigationItem
的部分就是您所看到的内容。如果您想要自定义标题颜色,您可以很容易地在每个视图控制器中执行如下操作。Every
UIViewController
has it's ownnavigationItem
, which (potentially) has atitleView
. When you push and pop view controllers in a navigation control, the parts of thenavigationItem
are what you are seeing. If you wanted a custom title color, you could very easily do something like the following in each of your view controllers.