ios - 使用全局 Tint 颜色作为 UINavigationBars backgroundColor

标签 ios objective-c uinavigationcontroller ios7

我需要将 UINavigationBars 背景颜色设置为与我的应用程序全局色调颜色相同的值。

这里的问题是,现在我的导航栏中的所有按钮都与其背景颜色相同。我现在可以将所有 UIBarButtons 文本颜色更改为白色,但这将完全无法使用。使用 UIAppearance API 似乎不是更好的方法。将 UIBarButton 项目的文本颜色设置为白色后,我的 UINavigationBar 中后退按钮的后退箭头仍然使用全局色调颜色绘制。

此外,如果我将全局色调颜色更改为白色,我将失去全局色调颜色为我们提供的所有灵 active (而且我的文本指示器现在将是白色,并且不会在白色背景上看到)

我想要什么:

enter image description here

我使用蓝色作为全局色调得到了什么

enter image description here

当使用蓝色作为全局色调颜色并将 uibarbutton 项目文本颜色设置为白色时我得到了什么(见后退按钮 - 它也应该是白色)

enter image description here

解决此问题的推荐方法是什么?

最佳答案

我建议你这样做:

UINavigationBar *navigationBar      = [UINavigationBar appearance];
navigationBar.tintColor             = [UIColor whiteColor];

将此代码放在 AppDelegate 的 didFinishLaunchingWithOptions: 方法中。

澄清一下,因为您显然对此不是很有经验:

barTintColor 是改变条形颜色的属性。 tintColor 改变交互对象的颜色(例如 UIBarButtonItems)

关于ios - 使用全局 Tint 颜色作为 UINavigationBars backgroundColor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20332952/

相关文章:

ios - 未调用 alertViewShouldEnableFirstOtherButton 委托(delegate)方法

ios - 如何在将 UIImage 保存到磁盘之前唯一标识它?

ios - 主视图从 ScrollView 中占用顶部空间?

iphone - 使用位置管理器发生内存泄漏

objective-c - 为什么不能在 objective-c 中创建抽象类

iphone - presentViewController :imagePickerController is popping my navigationController?

android - Phonegap (3.3.0) FileReader readAsText() 不工作

ios - dvc 无法在新版 iOS 的 textview 中传递 NSString 数据?

ios - 如何实现 UIViewControllerContextTransitioning 兼容交互转场

iphone - 如何在基于 View 的应用程序中添加导航 Controller