我知道怎么做来改变UINavigationBar的背景图像

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"nabbar"] forBarMetrics:UIBarMetricsDefault];

我知道如何在每Views条中设置不同的 colored颜色 .现在我想把背景色without using an imageapp delegate改成纯色.我不想每次都从每个视图设置它,我也不想写CGRect.

我try 了[[UINavigationBar appearance] setBackgroundColor:[UIColor colorWithRed:33/255.0 green:34/255.0 blue:36/255.0 alpha:1.0]];次,但没有成功,我在app delegate中找不到有效的代码.

谁能给我指一下正确的方向吗?

推荐答案

你可以用[[UINavigationBar appearance] setTintColor:myColor];

从iOS 7开始,您需要设置[[UINavigationBar appearance] setBarTintColor:myColor];[[UINavigationBar appearance] setTranslucent:NO].

[[UINavigationBar appearance] setBarTintColor:myColor];
[[UINavigationBar appearance] setTranslucent:NO];

Ios相关问答推荐

Jenkins node 无法运行fastlane命令-未找到命令

更改文本在Flutter 中的位置

为什么AVSpeechSynthesizer复制的信息比我的文本多?

WatchConnectivity - 从手表配套应用程序在 iOS 设备上启动 AVPlayer

NSError 错误领域: "CBATTErrorDomain" 代码: 128 0x0000000282b111a0

iOS应用启动时崩溃问题解决方法-NO_CRASH_STACK-DYLD 4个符号丢失

占位符文本未显示在 TextEditor 上

如何根据条件快速将返回类型设为 LinearGradient 或 AngularGradient?

如何在保持纵横比的同时zoom UIView 的内容以适应目标矩形?

iOS 中是否有用于自定义振动的 API?

如何在导航栏右侧添加多个 UIBarButtonItem?

无法验证客户端 3000

如何在 iOS 的 xib 中设置十六进制 colored颜色 代码

当键盘出现在 iOS 中时,将 UIView 上移

如何使用 Contacts Framework 获取 iOS 9 中的所有联系人记录

UITextView 从文本的底部或中间开始

iOS UITextView 或 UILabel 带有可点击的动作链接

如何关闭 iOS 键盘?

Swift 中的日期到毫秒和回溯到日期

UICollectionView:必须用非零布局参数初始化