Intrinsic Content Size: Swift’s Sizing Mystery
What is it?
You may have come across intrinsicContentSize, perhaps through work with UICollectionView
or similar.
But what is it, and what can you do to improve you understanding of this for your journey in Swift?
Terminology
frame: A rectangle which describes a view’s location and size in it’s superview’s coordinate system
intrinsicContentSize: The natural size for the receiving view, considering only properties of the view itself
The Basics
I’ve already created a tips article on intrinsic content size which covers something about intrinsicContentSize
. I’ve never been happy with that article as it’s just too abstract.
I just want to see what intrinsicContentSize
and frame mean for views in UIKit
. This is that article.
The Example
In the attached repo is a simple view controller (placed in a UINavigationController
) that gives us the opportunity to…