LayoutWriter
public struct LayoutWriter : Element
A parent element which allows arbitrary, custom layout and positioning of its children.
Instead of creating a custom Element
with a custom Layout
, you might use
this element to create a customized layout in a more lightweight way.
LayoutWriter { context, layout in
layout.add(with: myFrame, child: myElement)
layout.add(with: myOtherFrame, child: myOtherElement)
layout.sizing = .unionOfChildren
}
-
Creates a new instance of the LayoutWriter with the custom layout provided by the builder.
The parameters to the closure are the
Context
, which provides information about the environment and sizing of the layout, and theBuilder
itself, which you use to add child elements to the layout.Declaration
Swift
public init(_ build: @escaping Build)
-
The builder used to create the custom layout.
Declaration
Swift
public let build: Build
-
Declaration
Swift
public var content: ElementContent { get }
-
Declaration
Swift
public func backingViewDescription(with context: ViewDescriptionContext) -> ViewDescription?
-
The builder is the primary surface area you interact with when using a
LayoutWriter
.It provides you the ability to manage the sizing and measurement of the final layout, alongside methods to add and manage the children of the layout.
See moreDeclaration
Swift
public struct Builder
-
Provides the relevant information about the context in which the layout is occurring.
See moreDeclaration
Swift
public struct Context
-
Controls the sizing calculation of the custom layout.
See moreDeclaration
Swift
public enum Sizing : Equatable
-
A child of the custom layout, providing its frame and element.
See moreDeclaration
Swift
public struct Child