override func viewDidLoad()
{
super.viewDidLoad()
self.navigationController?.navigationBar.barTintColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1.0)
let attr: NSMutableDictionary! = [NSForegroundColorAttributeName: UIColor.whiteColor()]
UINavigationBar.appearance().titleTextAttributes = attr
self.view.backgroundColor = UIColor.whiteColor()
}
'Cannot assign value of type 'NSMutableDictionary!' to type '[String : AnyObject]?''
在这条线
UINavigationBar.appearance().titleTextAttributes = attire
,如果我将其更改为
UINavigationBar.appearance().titleTextAttributes = attr as! [String: AnyObject]
虽然没有错误,但它可以改变文本的颜色。为什么?
请详细说明该代码如何回答问题。 – JAL