![]() Our first attempt at a compositional layout. Our sizing logic from UICollectionViewDelegateFlowLayout is no longer required, as that behavior is already captured in our layout declaration. The photos are categorized into sections, but that won’t come into play just yet.Įxtension PhotosCollectionViewController : UICollectionViewDelegateFlowLayout ()Īnd that’s it. It’s just a standard, everyday UICollectionViewDataSource that returns a cell for each square photo we want to display. Our flow layout and compositional layout will use the exact same data source. Then, we’ll expand on our compositional layout solution while introducing some of the more powerful new features.Ī basic grid built with UICollectionViewFlowLayout. We’ll start by reviewing how to build a grid with a flow layout, and then show you how to achieve the same design using a compositional layout while exploring the new APIs. More advanced customization often meant subclassing UICollectionViewFlowLayout, or creating your own layout by subclassing UICollectionViewLayout directly. ![]() Back to Basicsįor years, UICollectionViewFlowLayout, a UICollectionViewLayout subclass, helped us to achieve simple line-based layouts with little configuration, and with little customization required to perfectly create a common grid layout. ![]() We made an Xcode project with all of the examples shown in this post. Our team has been making use of compositional layouts ever since, and we’d like to help you get started as well. UICollectionViewCompositionalLayout promised to simplify collection view layouts using a more declarative approach without the need to subclass to achieve customization-and it delivered. At WWDC 2019, Apple introduced and later documented an unbelievable API for building complex layouts with ease.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |