DevPrep

All topics › Auto Layout

What is intrinsic content size?

Junior PRO

The gist

Intrinsic content size is a view's "natural" size that it computes from its own content without looking at its neighbors: a UILabel from its text and font, a UIImageView from the image size, a UIButton from its title, icon and contentInsets, a UISwitch is fixed. Auto Layout turns this value into a pair of optional constraints on width and height (content hugging and compression resistance), so such views need no explicit width/height: positioning them is enough.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store