Understanding Intrinsic Content Size in iOS Development

Because it’s tricky

Steven Curtis
5 min readJul 29, 2024
Photo by charlesdeluvio on Unsplash

Terminology

frame: A rectangle which describes a view’s location and size in its superview’s coordinate system

intrinsicContentSize: The natural size for the receiving view, considering only properties of the view itself

What is Intrinsic Content Size?

Each view should have an ideal amount of space that will display it’s content. This would mean (for example) you would be able to place that view onto a storyboard without giving Auto Layout height and width constraints.

For example a UILabel has a width and height that is based on the size of the text it contains. This simplifies layouts, as rather than specifying the width and height of a component we can tell Auto Layout where to display the component and Auto Layout.

Importance

Intrinsic content size has a role in creating dynamic and responsive layouts as it allows view to automatically adjust size based on content.

This means:

- we avoid hardcoding dimensions

- we ensure that the UI adapts gracefully to content sizes

--

--