开发者

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

开发者 https://www.devze.com 2022-12-15 16:32 出处:网络
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 U

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.


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]];


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

0

精彩评论

暂无评论...
验证码 换一张
取 消