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