Start building a new collection-view-focused app from scratch. Compose layouts using UICollectionViewCompositionalLayout
Watch the complete course here:
https://www.raywenderlich.com/5429927...
This course is part of our iOS and Swift for Beginners Learning Path. You're ready for this course if you're working through that learning path in order, or you're someone who has just a little bit of iOS and Swift experience.
You'll start off by building a simple collection view that displays numbers is rows and grids using brand new diffable data sources and compositional layout APIs.
Then, you'll take a small detour to build an emoji library app using pre-iOS 13 API by implementing data sources and flow layouts.
Finally, you'll combine the two approaches to build a RayWenderlich.com library app that lets you browse courses.
Throughout the course, you'll practice everything you learn with hands-on challenges.
This course isn’t suited for intermediate or advanced developers. If that’s you, check out our intermediate or advanced video courses for more ways to level-up your developer skills!
From Apple's Documentation:
https://developer.apple.com/documenta...
An object that manages an ordered collection of data items and presents them using customizable layouts.
When adding a collection view to your user interface, your app’s main job is to manage the data associated with that collection view. The collection view gets its data from the data source object, which is an object that conforms to the UICollectionViewDataSource Protocol and is provided by your app. Data in the collection view is organized into individual items, which can then be grouped into sections for presentation. An item is the smallest unit of data you want to present. For example, in a photos app, an item might be a single image. The collection view presents items onscreen using a cell, which is an instance of the UICollectionViewCell class that your data source configures and provides.
In addition to its cells, a collection view can present data using other types of views too. These supplementary views can be things like section headers and footers that are separate from the individual cells but still convey some sort of information. Support for supplementary views is optional and defined by the collection view’s layout object, which is also responsible for defining the placement of those views.
Besides embedding it in your user interface, you use the methods of UICollectionView object to ensure that the visual presentation of items matches the order in your data source object. Thus, whenever you add, delete, or rearrange data in your collection, you use the methods of this class to insert, delete, and rearrange the corresponding cells. You also use the collection view object to manage the selected items, although for this behavior the collection view works with its associated delegate object.
Collection Views and Layout Objects
A very important object associated with a collection view is the layout object, which is a subclass of the UICollectionViewLayout class. The layout object is responsible for defining the organization and location of all cells and supplementary views inside the collection view. Although it defines their locations, the layout object does not actually apply that information to the corresponding views. Because the creation of cells and supplementary views involves coordination between the collection view and your data source object, the collection view actually applies layout information to the views. Thus, in a sense, the layout object is like another data source, only providing visual information instead of item data.
You normally specify a layout object when creating a collection view but you can also change the layout of a collection view dynamically. The layout object is stored in the collectionViewLayout property. Setting this property directly updates the layout immediately, without animating the changes. If you want to animate the changes, you must call the setCollectionViewLayout(_:animated:completion:) method instead.
If you want to create an interactive transition—one that is driven by a gesture recognizer or touch events—use the startInteractiveTransition(to:completion:) method to change the layout object. That method installs an intermediate layout object whose purpose is to work with your gesture recognizer or event-handling code to track the transition progress. When your event-handling code determines that the transition is finished, it calls the finishInteractiveTransition() or cancelInteractiveTransition() method to remove the intermediate layout object and install the intended target layout object.
Смотрите видео Configuring the Layout Object - Beginning CollectionViews in iOS - Swift 5, Xcode 11 - raywenderlich онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Kodeco 31 Март 2020. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 3,303 раз и оно понравилось 47 посетителям.