Dynamic Text Resizing in Swift

Creating a great user experience lies in making every interaction feel nature and intended to the user.

In a recent project, to make interactions feel more catered, I needed a UILabel to have it’s text scale to fit its bounds to the best extent that it can.


The implementation can be extended for any UI element (such as UILabel):

let label = UILabel()
label.font = UIFont.preferredFont(forTextStyle: .headline)

iOS Font Sizes

(-Light on iOS <=10)

Leave a Reply