iPhone: Possible to change the color of just the prompt of the UINavigationBar?

倾然丶 夕夏残阳落幕 提交于 2021-02-08 05:56:09

问题


I'm wondering if I can change the background color of just the prompt of the UINavigationBar (e.g. to red, while the rest of the navigation bar stays black), so I can use the prompt property of the UINavigationItem to display status / error messages as a one-liner.


回答1:


Nope. But you can set the prompt to an empty string, and place a red-colored label on top of it.




回答2:


This is an old question, but since the introduction of appearance there is a much easier way to setting prompt color (and other properties) than adding a subview.

in didFinishLaunchingWithOptions put

[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor theColorYouWantYourPromptToBe], UITextAttributeTextColor, otherVariables, nil]];


来源:https://stackoverflow.com/questions/2027573/iphone-possible-to-change-the-color-of-just-the-prompt-of-the-uinavigationbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!