To change the font size of a UILabel in Swift, we can use the font.withSize()
function:
label.font = label.font.withSize(20)
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)
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.
The Complete iOS App Development Bootcamp
Disclosure: This website may contain affiliate links, meaning when you click the links and make a purchase, we receive a commission.