One Logo Pool Ball
SwiftUICore · IOS API REFERENCE

LayoutProperties

struct · iOS 16.0+ · SDK 27.1

struct LayoutProperties

Layout-specific properties of a layout container. This structure contains configuration information that's applicable to a layout container. For example, the ``stackOrientation`` value indicates the layout's primary axis, if any. You can use an instance of this type to characterize a custom layout container, which is a type that conforms to the ``Layout`` protocol. Implement the protocol's ``Layout/layoutProperties-5rb5b`` property to return an instance. For example, you can indicate that your layout has a vertical stack orientation: extension BasicVStack { static var layoutProperties: LayoutProperties { var properties = LayoutProperties() properties.stackOrientation = .vertical return properties } } If you don't implement the property in your custom layout, the protocol provides a default implementation that returns a `LayoutProperties` instance with default values.

Members (3)

get · iOS 16.0+

stackOrientation

TypeScript
get stackOrientation(): (Axis) | null
Swift declaration
var stackOrientation: Axis?

The orientation of the containing stack-like container. Certain views alter their behavior based on the stack orientation of the container that they appear in. For example, ``Spacer`` and ``Divider`` align their major axis to match that of their container. Set the orientation for your custom layout container by returning a configured ``LayoutProperties`` instance from your ``Layout`` type's implementation of the ``Layout/layoutProperties-5rb5b`` method. For example, you can indicate that your layout has a ``Axis/vertical`` major axis: extension BasicVStack { static var layoutProperties: LayoutProperties { var properties = LayoutProperties() properties.stackOrientation = .vertical return properties } } A value of `nil`, which is the default when you don't specify a value, indicates an unknown orientation, or that a layout isn't one-dimensional.

set · iOS 16.0+

stackOrientation

TypeScript
set stackOrientation(value: (Axis) | null)
Swift declaration
var stackOrientation: Axis?

The orientation of the containing stack-like container. Certain views alter their behavior based on the stack orientation of the container that they appear in. For example, ``Spacer`` and ``Divider`` align their major axis to match that of their container. Set the orientation for your custom layout container by returning a configured ``LayoutProperties`` instance from your ``Layout`` type's implementation of the ``Layout/layoutProperties-5rb5b`` method. For example, you can indicate that your layout has a ``Axis/vertical`` major axis: extension BasicVStack { static var layoutProperties: LayoutProperties { var properties = LayoutProperties() properties.stackOrientation = .vertical return properties } } A value of `nil`, which is the default when you don't specify a value, indicates an unknown orientation, or that a layout isn't one-dimensional.

init · iOS 16.0+

init

TypeScript
static init(): LayoutProperties
Swift declaration
init()

Creates a default set of properties. Use a layout properties instance to provide information about a type that conforms to the ``Layout`` protocol. For example, you can create a layout properties instance in your layout's implementation of the ``Layout/layoutProperties-5rb5b`` method, and use it to indicate that the layout has a ``Axis/vertical`` orientation: extension BasicVStack { static var layoutProperties: LayoutProperties { var properties = LayoutProperties() properties.stackOrientation = .vertical return properties } }

Skipped declarations

No declarations were skipped in this snapshot.

All SwiftUICore types →