Change textColor of UINavigationBar “prompt”?

别说谁变了你拦得住时间么 提交于 2019-12-07 08:04:17

问题


Any (supported) way of doing this? IIRC it usually switches over by itself to a white color at some point when using a "darker than X" tintColor, but we seem to be just on the edge with our scheme.


回答1:


I guess the only way to really do it is to use a custom titleView for each UINavigationItem. You can use a UILabel and try to match the built-in navigation title style as closely as you can, then assign your own text color.




回答2:


It's possible in iOS5:

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



回答3:


And for iOS 7 you can make this to set the prompt to White Color. Please note that it will also change the color of the navbar title.

[[[self navigationController] navigationBar] setTitleTextAttributes:
  @{NSForegroundColorAttributeName:[UIColor whiteColor]}];


来源:https://stackoverflow.com/questions/1491345/change-textcolor-of-uinavigationbar-prompt

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