无法同时更改导航栏文本字体和颜色
Can't change Navigation bar text font and color at the same time
我想同时更改文本字体和颜色,但不幸的是只有其中一个发生了变化。请问我的问题在哪里?
self.title = "Hello Members"
if let font = UIFont(name: "Avenir-Body", size: 15) {
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.orangeColor()]
self.navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName: font]
}
试试这个:
var attributes = [
NSForegroundColorAttributeName: UIColor.greenColor(),
NSFontAttributeName: UIFont(name: "Avenir", size: 30)!
]
self.navigationController?.navigationBar.titleTextAttributes = attributes
我想同时更改文本字体和颜色,但不幸的是只有其中一个发生了变化。请问我的问题在哪里?
self.title = "Hello Members"
if let font = UIFont(name: "Avenir-Body", size: 15) {
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.orangeColor()]
self.navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName: font]
}
试试这个:
var attributes = [
NSForegroundColorAttributeName: UIColor.greenColor(),
NSFontAttributeName: UIFont(name: "Avenir", size: 30)!
]
self.navigationController?.navigationBar.titleTextAttributes = attributes