iOS 9 use UIFont(name: ".SFUIText) found nil

Viewed 265

I use this code and build in ios9 device and crash.
Have any idea to fix it?
Thanks.

let font = UIFont(name: ".SFUIText", size: 12)!
2 Answers

There is no need to hardcode name of the system font, which is not documented and can change. Use the system font directly:

UIFont.systemFont(ofSize: 12)

You can try this. Enclose the font name with quotation.

label.font = UIFont(name: ".SFUIText", size: 12)
Related