0

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)]
1
  • This doesn't compile Commented Sep 17, 2015 at 15:11

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

And you might like to file a bug report with Apple asking for a better error message from the Swift compiler in this situation.
Beautiful! Thank you very much, I appreciate the help. I'll be sure to file that bug report

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.