Hello, this is Rasel Miah from iOS team. This time I will discuss about the modern way of creating collection views layout using the new declarative API called Compositional Layout
.
For years, UICollectionViewFlowLayout
helped us to create a simple grid layout with a little customization. We can also create a complex layout by subclassing UICollectionViewFlowLayout
, or creating our own layout by subclassing UICollectionViewLayout
.
But it is time consuming and of course not easy to make.
Gradly, at WWDC 2019, Apple introduced Compositional Layout
which is a powerful and declarative API that allows us to build a large layout by stitching together smaller layout groups. We'll start by creating a simple grid using UICollectionViewFlowLayout
and the try to achieve the same design using the Compositional Layout
. After that I'll show you how to build a complex layout using the new API.