iosuifontuifontdescriptor

Setting UIFont Weight


In iOS 8 in order to get Helvetica Neue in the thin variation the following code would work

UIFont.systemFontOfSize(50, weight: UIFontWeightThin)

In iOS 9 the system font changed to San Francisco, so I can no longer do this. I absolutely must use Helvetia in this app and can't figure out how to set the font weight. This is the code I am currently using.

    timeSelectedLabel.font = UIFont(name: "Helvetica Neue", size: CGFloat(50))

I know there is a constructor which accepts a UIFontDescriptor. Not sure how to use that though. Any thoughts are appreciated!

Note: Before you mark this as duplicate know that the only 2 posts are either unanswered or don't currently work.


Solution

  • All I had to do was specify the weight after a dash like so.

    UIFont(name: "HelveticaNeue-Thin", size: CGFloat(50))