How Do I Change The Font Size Of UILabel In Swift

By Eddy Chung

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, you'll love my free guide: Secrets To iOS Development. Speed up your learning curve - hundreds of students have already downloaded. Thanks for reading!
Profile Picture of Eddy Chung

Eddy Chung

I am a professional iOS developer in Silicon Valley. I teach iOS development on ZeroToAppStore.com. If you'd like to learn more about me click here or you can contact me at: eddy@zerotoappstore.com

Similar Posts