Objective C:如何更改导航栏中的文本颜色
我通过以下代码更改了导航栏颜色
navconFvc.navigationBar.tintColor = [UIColor colorWithHexString:@"faf6f5"];
该代码有效,但文本颜色也需要更改(请参见下面的屏幕截图)。此外,右侧的刷新按钮徽标也会受到影响
如果我导航到另一个页面,也会出现同样的问题在堆栈中
问题:如何更改
- 标题文本
- 后退按钮文本和
- 右栏按钮 的颜色图标颜色?
在我更改导航栏的背景颜色之后?
I have changed my navigation bar color via the following code
navconFvc.navigationBar.tintColor = [UIColor colorWithHexString:@"faf6f5"];
The code worked but the text color also needs to be changed (see screenshot below). Also the refresh button logo on the right is affected as well
The same issue occurs if I navigate to another page in the stack
Question: How can I change the color of the
- title text
- Back button text and
- right bar button icon color?
After I changed the background color of the navbar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 iOS 7 中,只需使用:
将 [UIColor WhiteColor] 更改为您想要的任何文本颜色
In iOS 7, just use:
Change [UIColor whiteColor] with whatever text color you want
对于标题,方法如下:
iPhone 导航栏标题文本颜色
自定义按钮的方法如下:
向 ui 导航添加按钮控制器底部栏
For the title here's the way:
iPhone Navigation Bar Title text color
And for the custom buttons here's the way:
adding buttons to ui navigation controller bottom bar
要更改文本颜色:
添加刷新按钮并为其着色:
影响导航栏背景的变量:
To change text color:
Adding refresh button and color it:
Variables that effect navigation bar background:
我只是组合了一个简单的 UIViewController 子类,它添加了一个可自定义的后退按钮,允许您更改文本颜色。它基本上添加了一些
willAppear
/willDisappear
逻辑来为后退按钮设置动画,就像UINavigationController
在使用leftBarButtonItem
时所做的那样财产。您可以将其扩展为也执行 rightBarButtomItem。https://github.com/typeoneerror/BBCustomBackButtonViewController
I just put together a simple
UIViewController
subclass that adds a customizable back button that allows you to change text colors. It basically adds somewillAppear
/willDisappear
logic to animate the back button the way theUINavigationController
does while using theleftBarButtonItem
property. You might extend this to also do the rightBarButtomItem as well.https://github.com/typeoneerror/BBCustomBackButtonViewController