Building a Flow Layout
Wrap items across lines dynamically.
What Is a Flow Layout?
A flow layout places items left to right, wrapping to a new row when the next item would overflow the available width—like tag chips or word wrapping.
The Plan
We will compute row breaks in a shared helper, return total height from sizeThatFits, and reuse the same computation in placeSubviews. Sharing logic keeps the two methods consistent.
All lessons in this course
- The Layout Protocol Basics
- Measuring Subviews
- Building a Flow Layout
- Layout Cache and Performance