What are the evolutions of the collection view?
Asked on 08/02/2024
1 search
The evolution of the collection view has been highlighted in several sessions at WWDC 2024, particularly in the context of SwiftUI and UIKit.
SwiftUI
In SwiftUI, the collection view has evolved to support more flexible and powerful compositions. Here are some key points:
-
List and ForEach Views:
- SwiftUI's
List
initializer can take a collection parameter, which is a convenience for creating aForEach
view. TheForEach
view generates views for each element in a collection and provides those to its container (SwiftUI essentials). - The
ForEach
view can be nested within theViewBuilder
, allowing for the combination of static and dynamic content within the same list (Demystify SwiftUI containers).
- SwiftUI's
-
Sections:
- SwiftUI's
Section
view allows for organizing data into sections with optional headers and footers. This is useful for creating more structured and organized lists (Demystify SwiftUI containers).
- SwiftUI's
-
Flexible Composition:
- SwiftUI supports flexible composition by allowing containers to be initialized using a
ViewBuilder
. This enables the creation of complex views by combining different types of content (Demystify SwiftUI containers).
- SwiftUI supports flexible composition by allowing containers to be initialized using a
UIKit
In UIKit, the collection view has also seen significant improvements:
-
List Environment Trait:
- UICollectionView list sections and UITableView now have the list environment trait, which describes the style of the list. This trait ensures that cells are styled appropriately in any given list, removing the need to know the style of the list when configuring a cell (What’s new in UIKit).
-
Compositional Layout:
- The use of compositional layout in UICollectionView allows for displaying lists in different styles depending on the context, such as the inset grouped appearance in portrait mode and a different style in landscape mode (What’s new in UIKit).
Relevant Sessions
These sessions provide a comprehensive overview of the advancements in collection views within both SwiftUI and UIKit, highlighting the increased flexibility, compositional capabilities, and improved styling options.

Enhance your UI animations and transitions
Explore how to adopt the zoom transition in navigation and presentations to increase the sense of continuity in your app, and learn how to animate UIKit views with SwiftUI animations to make it easier to build animations that feel continuous.

A Swift Tour: Explore Swift’s features and design
Learn the essential features and design philosophy of the Swift programming language. We’ll explore how to model data, handle errors, use protocols, write concurrent code, and more while building up a Swift package that has a library, an HTTP server, and a command line client. Whether you’re just beginning your Swift journey or have been with us from the start, this talk will help you get the most out of the language.

What’s new in UIKit
Explore everything new in UIKit, including tab and document launch experiences, transitions, and text and input changes. We’ll also discuss better-than-ever interoperability between UIKit and SwiftUI animations and gestures, as well as general improvements throughout UIKit.