Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Change Font Style in Swift

Tags:

ios

swift

uifont

I'm trying to figure out how to change the style of a font to "Thin". Does anyone know how to do this?

Here's my best try, but it doesn't work:

m.font = UIFont(name: "Apple SD Gothic Neo", style: "Thin", size: 8.0)
like image 520
Collin O. Avatar asked Dec 04 '15 15:12

Collin O.


People also ask

How do I change text font in Swift?

Change Font And Size Of UILabel In Storyboard To change the font or the size of a UILabel in a Storyboard or . XIB file, open it in the interface builder. Select the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.

How do I change the font of text in Xcode?

Press xcode->preferences. select fonts and colors. select ANY font in the list and press cmd+a (select all fonts) select font size for all editor fonts at the bottom of the window.


1 Answers

The way I have seen it is AppleSDGothicNeo-Thin, No spaces, and a dash style. So your code would be

m.font = UIFont(name: "AppleSDGothicNeo-Thin", size: 8.0)

Edit:

I have come to understand why you use the font this way.

If you add a custom font to your project, it has a name of "SuperAwesomeFont-Light.ttf". So it makes sense that you just use the file name for the name of the font.

like image 88
Caleb Kleveter Avatar answered Sep 21 '22 15:09

Caleb Kleveter