Reputation: 33
I have a problem with a custom font in my project. I tried both ways: by code and interface builder.
I added TeamSpiritNF.ttf to the project and added it to the info.plist (Fonts provided by application).
Then in the code I entered this:
self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "TeamSpiritNF", size: 30)!]
When entering the screen in the simulator the App crashes:
fatal error: unexpectedly found nil while unwrapping an Optional value
But the same line works fine if I change the font name to Helvetica for example.
And if I use this font for a label in the interface builder (where I can select it from the dropdown), it is shown correct in the preview. But when I run the application in the simulator entering that screen is delayed and the label uses Helvetica Neue instead of TeamSpiritNF.
Anyone has an idea what the problem could be?
Upvotes: 3
Views: 7005
Reputation: 9409
Upvotes: 15
Reputation: 567
Upvotes: 7