Common Elements
-
Acts as an accessibility container for any accessible subviews.
Accessible subviews are found using the following algorithm:
Recurse subviews until a view is found that either
- has
isAccessibilityElement
set totrue
or
If an accessibility element is found, we add it to the
See moreaccessibilityElements
and terminate the search down that branch. If a container is found, the elements returned from the container are added to theaccessibilityElements
and the search down that branch is also terminated.Declaration
Swift
public struct AccessibilityContainer : Element
- has
-
Wraps an element tree with a modified environment.
By specifying environmental values with this element, all child elements nested will automatically inherit those values automatically. Values can be changed anywhere in a sub-tree by inserting another
See moreAdaptedEnvironment
element.Declaration
Swift
public struct AdaptedEnvironment : Element
-
An element that dynamically builds its content based on the environment.
Use this element to build elements whose contents may change depending on the
Environment
.Example
EnvironmentReader { environment -> Element in MyElement( foo: environment.foo ) }
Seealso
ProxyElementSeealso
EnvironmentDeclaration
Swift
public struct EnvironmentReader : Element
-
Aligns a content element within itself. The vertical and horizontal alignment may be set independently.
When using alignment mode
.fill
, the content is scaled to the width or height of theAligned
element.For other modes, the size of the content element is determined by calling
See moremeasure(in:)
on the content element – even if that size is larger than the wrapping element.Declaration
Swift
public struct Aligned : Element
-
Centers a content element within itself.
The size of the content element is determined by calling
See moremeasure(in:)
on the content element – even if that size is larger than the wrappingCentered
element.Declaration
Swift
public struct Centered : ProxyElement
-
Displays a list of items in a linear vertical layout.
See moreDeclaration
Swift
public struct Column : StackElement
-
Constrains the measured size of the contained element in the ranges specified by the
width
andheight
properties.There are several constraint types available for each axis. See
ConstrainedSize.Constraint
for a full list and in-depth descriptions of each.Notes
An important note is that the constraints of
See moreConstrainedSize
are authoritative during measurement. For example, if yourConstrainedSize
specifies.atLeast(300)
forwidth
, and theConstrainedSize
is asked to measure within aSizeConstraint
that is at most 100 points wide, the returned measurement will still be 300 points. The same goes for the height of theConstrainedSize
.Declaration
Swift
public struct ConstrainedSize : Element
-
An element that sizes its children equally, stacking them in the primary axis according to the specified
direction
and spacing them according to the specifiedspacing
. In the secondary axis, children are justified to fill the space of the largest child.Note
A stack measures itself by determining its largest child in each axis, and in the case of the primary axis, multiplying bychildren.count
(accounting forspacing
as necessary).Declaration
Swift
public struct EqualStack : Element
-
An element that dynamically builds its content based on the available space.
Use this element to build elements whose contents may change responsively to different layouts.
Example
See moreGeometryReader { (geometry) -> Element in let image: UIImage switch geometry.constraint.width.maximum { case ..<100: image = UIImage(named: "small")! case 100..<500: image = UIImage(named: "medium")! default: image = UIImage(named: "large")! } return Image(image: image) }
Declaration
Swift
public struct GeometryReader : Element
-
Displays text content.
See moreDeclaration
Swift
public struct Label : ProxyElement
-
Stretches all of its child elements to fill the layout area, stacked on top of each other.
During a layout pass, measurement is calculated as the max size (in both x and y dimensions) produced by measuring all of the child elements.
View-backed descendants will be z-ordered from back to front in the order of this element’s children.
See moreDeclaration
Swift
public struct Overlay : Element
-
Displays a list of items in a linear horizontal layout.
See moreDeclaration
Swift
public struct Row : StackElement
-
A solid line, parallel to the x or y axis, with a fixed thickness but unconstrained in length, suitable for use as a separator.
See moreDeclaration
Swift
public struct Rule : ProxyElement
-
Allows users to pick from an array of options.
See moreDeclaration
Swift
public struct SegmentedControl : Element, Measurable