简体   繁体   中英

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.

My Navigation Controller has a yellow background color. Because of that the color of the title label should always be black , even in DARK MODE since yellow and white is too similar.

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 .

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM