ios - Storyboard中带有嵌入式导航 Controller 的 UINavigationBar 自定义颜色

标签 ios xcode uinavigationcontroller uinavigationbar

这是一个愚蠢的问题,但我真的很想知道,如何在我的默认 UINavigationBar 中添加自定义颜色,它实际上是从 Editor 添加到我的 viewController > 嵌入 > NavigationController

我添加这个:

[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:244/255 green:119/255 blue:39/255 alpha:1.0]];

在我的 AppDelegat 中,在 didFinishLaunchingWithOptions 中,但没有任何反应。谁能告诉我该怎么做?
非常感谢。

最佳答案

在您的 View Controller 中,将此添加到您的 viewDidLoad 方法中:

[[[self navigationController] navigationBar] setBarTintColor:[UIColor yourColor];

如果您的导航 Controller 是您的 Root View Controller ( Storyboard 中的第一个 View Controller ),您可以在应用委托(delegate)中使用它:

[[(UINavigationController*)self.window.rootViewController navigationBar] setBarTintColor:[UIColor yourColor]];

关于ios - Storyboard中带有嵌入式导航 Controller 的 UINavigationBar 自定义颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28781555/

相关文章:

iOS - 方法(在另一个类中)执行了两次

ios - iOS 版 Air : Testing swipe gesture on my mac

c# - 解析数组中存储的json数据字符串

objective-c - 是否可以在 Xcode 中创建数据断点?

ios - 我真的需要导航 Controller 吗?

ios - 以编程方式导航到另一个 View Controller /场景

iphone - 在静态 UITableView 中添加新部分

xcode - 重构 ViewControllers - 错误 : Storyboard both contain a view controller with same identifier

objective-c - pkgbuild postinstall 脚本在其他人的 Mac 上导致 "Installation failed"

ios - 如何设置右侧导航栏按钮标题