Contents

Custom layout

Place views in custom arrangements and create animated transitions between layout types.

Overview

You can create complex view layouts using the built-in layout containers and layout view modifiers that SwiftUI provides. However, if you need behavior that you can’t achieve with the built-in layout tools, create a custom layout container type using the Layout protocol. A container that you define asks for the sizes of all its subviews, and then indicates where to place the subviews within its own bounds.

[Image]

You can also create animated transitions among layout types that conform to the Layout procotol, including both built-in and custom layouts.

For design guidance, see Layout in the Human Interface Guidelines.

Topics

Creating a custom layout container

Configuring a custom layout

Associating values with views in a custom layout

Transitioning between layout types

See Also

View layout