user3353890
user3353890

Reputation: 1891

Customizing the NavigationBar using Swift

When I try adding custom attributes to my navigationBar, I get the error: "could not find an overload for '/' that accepts the supplied arguments"...This only started occurring with the most recent Xcode update. Any help is appreciated. Thanks!

navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: "AvenirNext-Bold", size: 30), NSForegroundColorAttributeName: UIColor(red: (102/255.0), green: (45/255.0), blue: (145/255.0), alpha: 1.0)]

Upvotes: 0

Views: 356

Answers (1)

matt
matt

Reputation: 534893

The problem is that UIFont(name: "AvenirNext-Bold", size: 30) returns an optional now. (As you correctly state, this only just started, in Xcode 6.1.) You need to unwrap it (put an exclamation mark after it) in order to use it in the attributes dictionary.

Upvotes: 1

Related Questions