Member-only story

What is intrinsicContentSize Anyway?

Make it fit the content

Steven Curtis
3 min readMar 25, 2021
Photo by Dalton Touchberry on Unsplash

Make it fit the content

Difficulty: Beginner | Easy | Normal | Challenging

This article is paired with a YouTube video, that covers similar ground.

Keywords and Terminology:

Auto Layout: A constraint-based layout system intrinsicContentSize: The natural size for the receiving view, considering only properties of the view itself

Prerequisites:

There aren’t any, although you will need to set up a project, although you might like to read through subclassing a UIView

What is this article about?

Each view should have an idea amount of space that will display it’s content. 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.

The Theory

Components often display content, and therefore have an instance property that allows it to communicate to the layout system what size it would like to be, based upon the content which it contains:

--

--

Responses (1)