What is intrinsicContentSize Anyway? Swift Content Tips.

Make it fit the content

Steven Curtis
3 min readApr 5, 2022
Photo by Skye Studios on Unsplash

Difficulty: Beginner | Easy | Normal | Challenging

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 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

--

--