iOS7导航栏文字颜色

Jas*_*agg 20 iphone ios7

我在将文本和状态栏文本颜色更改为白色时遇到问题.

我希望所有的黑色文字都是白色的,任何想法?

我见过很多解决方案,但似乎没有一个在iOS 7上运行

Leo*_*eon 56

我的解决方案是将以下内容添加到AppDelegate:

[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
Run Code Online (Sandbox Code Playgroud)

斯威夫特3:

UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
Run Code Online (Sandbox Code Playgroud)


Ric*_*man 29

要将标题文字颜色变为白色,请将其放在viewDidLoad中

self.navigationController.navigationBar.titleTextAttributes = @{UITextAttributeTextColor : [UIColor whiteColor]}
Run Code Online (Sandbox Code Playgroud)

要将状态栏文本颜色更改为白色,请将其添加到视图中

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Run Code Online (Sandbox Code Playgroud)

  • 伟大的第一部分工作,但我不得不将其更改为:self.navigationController.navigationBar.titleTextAttributes = @ {NSForegroundColorAttributeName:[UIColor whiteColor]}; 但第二部分不起作用.我添加到AppDelegate.m? (2认同)

Luc*_*cas 12

您可能想要做几件事.

1)要更改标题的颜色:

self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};
Run Code Online (Sandbox Code Playgroud)

2)要更改条形按钮的颜色:

self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
Run Code Online (Sandbox Code Playgroud)

3)通过整个应用程序使状态栏文本颜色变为白色:

在你的项目plist文件:

  • 状态栏样式: UIStatusBarStyleLightContent
  • 查看基于控制器的状态栏外观: NO
  • 状态栏最初是隐藏的: NO


Mub*_*ikh 5

您可以使用以下内容:

[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName]];
Run Code Online (Sandbox Code Playgroud)


Jas*_*agg 3

这就是我所做的..

执行以下操作,使整个应用程序的状态栏文本颜色变为白色。

在您的项目plist文件上:

状态栏样式:UIStatusBarStyleLightContent

View controller-based status bar appearance: NO

Status bar is initially hidden: NO

如果您希望整个应用程序具有相同的行为,则无需实现preferredStatusBarStyle或调用。setNeedsStatusBarAppearanceUpdate