how do i use compositional layout
Generated on 7/31/2024
1 search
To use compositional layout, you can refer to the session titled "What’s new in UIKit" from WWDC 2024. This session discusses how compositional layout is used to display a list of locations, favorites, and tags in different styles depending on the context. For example, in portrait mode, the browse list uses the inset grouped appearance, while in landscape mode, it is presented in a split view controller sidebar.
Here's a brief overview of how compositional layout is implemented:
- Define the Layout: You start by defining the layout for your collection view. This involves specifying the sections and items within those sections.
- Configure the Appearance: Depending on the context (e.g., portrait or landscape), you can configure the appearance of the list. For instance, the sidebar style is used in landscape mode.
- Manual Configuration: In some cases, you may need to manually pick the content and background configurations based on the appearance style.
For more detailed information, you can watch the session What’s new in UIKit starting at 08:53.
Additionally, if you are working with SwiftUI, the session "Demystify SwiftUI containers" provides insights into how composition is used in SwiftUI. For example, you can use a ForEach
view to create a list that combines static and dynamic content. This session also covers how to refactor your container to support flexible composition using a view builder.
For more details on composition in SwiftUI, you can watch the session Demystify SwiftUI containers starting at 03:17.
Demystify SwiftUI containers
Learn about the capabilities of SwiftUI container views and build a mental model for how subviews are managed by their containers. Leverage new APIs to build your own custom containers, create modifiers to customize container content, and give your containers that extra polish that helps your apps stand out.
Render Metal with passthrough in visionOS
Get ready to extend your Metal experiences for visionOS. Learn best practices for integrating your rendered content with people’s physical environments with passthrough. Find out how to position rendered content to match the physical world, reduce latency with trackable anchor prediction, and more.
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.
Migrate your TVML app to SwiftUI
SwiftUI helps you build great apps on all Apple platforms and is the preferred toolkit for bringing your content into the living room with tvOS 18. Learn how to use SwiftUI to create familiar layouts and controls from TVMLKit, and get tips and best practices.
SwiftUI essentials
Join us on a tour of SwiftUI, Apple’s declarative user interface framework. Learn essential concepts for building apps in SwiftUI, like views, state variables, and layout. Discover the breadth of APIs for building fully featured experiences and crafting unique custom components. Whether you’re brand new to SwiftUI or an experienced developer, you’ll learn how to take advantage of what SwiftUI has to offer when building great apps.