Introduction
iOS label controls can be configured to autoshrink. This automatically reduces the size of the font used to draw them to fit the text assigned to them into their frame. Their frame is the bounding rectangle they are drawn into. The size of the frame can be set in Interface Builder using constraints.
In this article I am going to describe my attempt to make an Autogrow label. My goal is to create a label that automatically increases its font size so that the text assigned to it fills its frame.
The method I am going to use is to set the label's font size to the maximum allowed by Interface Builder and enable autoshrink. My hope is that the font will then be shrunk until the text just fits in the frame.
This is a three step process:
1. Use constraints to set the size of the label to be relative to the size of the view.
2. Set the label's autoshrink attributes.
3. Increase the label's font size.