如何改变iOS7的按钮颜色

Jes*_*ala 19 back-button ios ios7 xcode5

我已经为iOS7开发了一款具有这种设计的应用程序

在此输入图像描述

你可以看到我的所有BackButton都有一个蓝色箭头(使用UINavigationController和segues),我想把它们变成红色,这是我的代码:

[UIBarButtonItem   appearance]setTintColor:(UIColorFromRGB(toolbarTintColor))];
[[UIBarButtonItem  appearance]setTitleTextAttributes:textAtributesDictionaryNavBarButtons forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)

但结果只适用于所有其他按钮,任何帮助,我会很感激

在此先感谢您的支持

Sim*_*een 35

导航栏的色调颜色属性确定iOS 7中其条形按钮项目文本的颜色.您要查找的代码如下所示:

[[UINavigationBar appearance] setTintColor:[UIColor redColor]];
Run Code Online (Sandbox Code Playgroud)

当然,用[UIColor redColor]你想要的任何颜色替换.

  • tintColor属性没有UI_APPEARANCE_SELECTOR所以我认为这个解决方案可能不可靠.Enrico Susatyo的回答似乎是正确的. (2认同)

yun*_*awa 12

将此代码放入App Delegate中:

Objective-C的

[self.window setTintColor:[UIColor redColor]];
Run Code Online (Sandbox Code Playgroud)

迅速

self.window?.tintColor = UIColor.redColor()
Run Code Online (Sandbox Code Playgroud)


Enr*_*tyo 10

如果您不想更改整个应用程序中的色调颜色,只想在一个导航栏上执行此操作,请执行以下操作:

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