大家好.... 我对 swift 2.0 中 navigationitem.title 中的 forground 颜色属性感到困惑。我已经尝试过了下面这些代码
navigationController?.navigationBar.barTintColor = UIColor(red: 0.3, green: 0.5, blue: 0.1, alpha: 1.0)
navigationController!.navigationBar.tintColor = UIColor.whiteColor()
navigationController?.navigationItem.titleView?.backgroundColor = UIColor.whiteColor()
navigationController?.navigationItem.titleView?.backgroundColor = UIColor.whiteColor()
它改变所有 View Controller 的 BarColor 和 BackButton 颜色(连接为 push segue) 但我无法访问 navigationItem.title color 方法。 o 如何更改此标题颜色?.. 提前致谢 :) ;)
最佳答案
如果您的意思是您正在尝试更改标题的文本颜色,则需要将以下内容放入 AppDelegate.swift< 的
:application(_:didFinishLaunchingWithOptions:)
中
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.whiteColor()]
关于ios - 如何在 iOS Swift 2.0 中更改导航项标题的背景色和前景色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38364574/