Reputation: 23
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()
}
It is said that
'Cannot assign value of type 'NSMutableDictionary!' to type '[String : AnyObject]?''
on this line
UINavigationBar.appearance().titleTextAttributes = attire
and if I change it to
UINavigationBar.appearance().titleTextAttributes = attr as! [String: AnyObject]
Although it has no error, but it can change the text's color. Why?
Upvotes: 0
Views: 1135
Reputation: 597
You can change color of title text navigation bar, for app in general. Just add this at your AppDelegate.swift in didFinishLaunchingWithOptions function.
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
Upvotes: 3
Reputation: 2690
Try this:
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.redColor()]
Upvotes: 0