【发布时间】:2018-10-17 20:40:40
【问题描述】:
我将导航栏颜色设置为 #479F46 ,在 iOS 10 中显示为 #5DA15D 但在 iOS 11 中显示为 #4D9D4E
- 我做错了什么?
- 以及如何解决这个问题?
我在应用委托中使用的代码
func setupNavigationController() {
UINavigationBar.appearance().barTintColor = UIColor.colorWithHexString(hexStr: "479F46")
UINavigationBar.appearance().tintColor = UIColor.white
let textAttributes = [NSAttributedStringKey.foregroundColor:UIColor.white]
UINavigationBar.appearance().titleTextAttributes = textAttributes
}
编辑 1
我使用isTranslucent = false 作为我的导航控制器对象,
nvc?.navigationBar.isTranslucent = false
但这似乎还不够,我添加了UINavigationBar.appearance().isTranslucent = false
正如 llb 建议的那样
现在两个视图操作系统版本都将颜色显示为#4D9D4E
我需要他们都显示为#479F46
【问题讨论】:
-
假设半透明不是问题,iOS 12 会显示什么?
-
您的
colorWithHexString中可能存在错误。谁知道它是做什么的?你没有显示它。 -
我又错过了一件事。您还应该按照@matt 的建议设置
UINavigationBar.appearance().backgroundColor = <Your color>并删除barTintColor。
标签: ios swift xcode uinavigationbar