Intrinsic Content Size

Under Auto Layout, a view’s content plays as important a role in its layout as its constraints. This is expressed through each view’s intrinsicContentSize. This method describes the minimum space needed to express the full content of the view without squeezing or clipping that data. It derives from the natural properties of the content each view presents.

For an image view, for example, this corresponds to the size of the image it presents. A larger image requires a larger intrinsic content size. For a label, this varies with its font and the amount of text. As the font changes, the label’s intrinsic content height varies. As the text length grows or shrinks in conjunction with the selected font, the label’s intrinsic content ...

Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.