[英]How to change the color of the title of a Navigation Bar in Swift 5?
I encountered a problem with my Navigation Controller in my app.我在我的应用程序中遇到了我的导航 Controller 的问题。
My Navigation Controller has a yellow background color.我的导航 Controller 具有黄色背景色。 Because of that the color of the title label should always be
black
, even in DARK MODE since yellow and white is too similar.因此,标题 label的颜色应始终为
black
,即使在暗模式下也是如此,因为黄色和白色太相似了。
I attached a picture illustrating my problem:我附上了一张图片来说明我的问题:
As you can see, I choose red color for the title color to check if this is working.如您所见,我选择红色作为标题颜色以检查这是否有效。 But the title
TEST
is still black in Light Mode and white in Dark Mode .但标题
TEST
在 Light Mode 中仍为黑色,在 Dark Mode 中为白色。
If you have an idea how to fix this issue so that the title color is always black, please let me now.如果您知道如何解决此问题以使标题颜色始终为黑色,请现在告诉我。 I tried a whole bunch of different solutions but none of them worked so far for me.
我尝试了一大堆不同的解决方案,但到目前为止没有一个对我有用。
Thanks for your help in advance.提前感谢您的帮助。
You could try你可以试试
navigationController?.navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.black]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.