I have a UIButton where the height must be able to grow according to the title that the button is given (dynamically).
I've set the button's title label to have numberOfLines = 0
, and set the LineBreakMode
to Word Wrap
. As a result, the button's text wraps as expected, but the button itself (I.E the tappable area) is not resized. See the following screenshot:
In this screenshot, the button's background colour is light gray to illustrate my point. As you can see, the button's title label (the blue text) is much larger than the background of the button. The button is constrained to be centred vertically and its leading/trailing anchors pinned to the superview so there is no constraint on it's height.
Am I missing a setting or trick that enables the button's area to grow relative to the title label?