I am writing an iOS app in Swift, and I want to use the system font, SF Pro. However, I can’t seem to figure out how to set the font weight at the same time as making the text italic. I know this was possible with Helvetica Neue with
UIFont(name: "HelveticaNeue-UltraLightItalic", size: 24.0)
But when using the system font, I can only seem to do one or the other like this
UIFont.italicSystemFont(ofSize: 24)
or
UIFont.systemFont(ofSize: 75.0, weight: UIFontWeightThin)
I have seen SF Pro Display Thin Italic in Font Book, and I know you can use it in editing apps like Sketch and Photoshop, but I have yet to find a way to get iOS to display it.
4
Answers
Here is one method:
That should give you something to build on – such as turning it into an
extension
to make it flexible.In general, use this site for fonts: http://iosfonts.com/
Found this extension here
Use the extension as:
As (an ugly) on-liner: