How Do I Change The Font Size Of UILabel In Swift

To change the font size of a UILabel in Swift, we can use the font.withSize() function:

label.font = label.font.withSize(20)

Change Font And Size Of UILabel In Swift

To change both the font and the size of text in a UILabel in Swift:

label.font = UIFont(name:"ArialRoundedMTBold", size: 20.0)

If you want to use the system font you can do this:

nameLabel.font = UIFont.systemFont(ofSize: 20.0)
nameLabel.font = UIFont.boldSystemFont(ofSize: 20.0)
nameLabel.font = UIFont.italicSystemFont(ofSize: 20.0)

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.

If you liked this post and want to learn more, check out The Complete iOS Developer Bootcamp. Speed up your learning curve - hundreds of students have already joined. Thanks for reading!

Eddy Chung

I teach iOS development on ZeroToAppStore.com.

Similar Posts