In this UICollectionView custom layout tutorial, you’ll create a layout inspired by the popular Pinterest app.
In the process, you’ll learn a lot about custom layouts, how to calculate and cache layout attributes, how to handle dynamically sized cells and much more.
Source: