我正在尝试编辑导航栏以获得白色文本,并且还有大小为20的“Chalkduster”字体。我当前的代码只跟随最后写的任何行 - 我如何组合这两个来获得颜色和字体?
代码:
self.navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: "Chalkduster", size: 15)!]
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
答案 0 :(得分:0)
将属性合并到一个字典中并传递它:
let attributes = [
NSFontAttributeName: UIFont(name: "Chalkduster", size: 15)!,
NSForegroundColorAttributeName: UIColor.whiteColor()
]
self.navigationController?.navigationBar.titleTextAttributes = attributes