ElementDimensions

public struct ElementDimensions : Equatable

An element’s size and its alignment guides in its own coordinate space.

You can access the size of the element through the width and height properties. You can access alignment guide values by subscripting with the specific alignment.

These dimensions are typically used when setting an alignment guide on a stack, with StackElement.add(...).

Example

// get the alignment guide value for `VerticalAlignment.center`, falling back to the default
// value if no alignment guide has been set
dimensions[VerticalAlignment.center]

// get the alignment guide value for `HorizontalAlignment.trailing`, or `nil` if none has been
// set.
dimensions[explicit: .trailing]

See Also

StackElement.add()

  • The element’s width

    Declaration

    Swift

    public internal(set) var width: CGFloat { get }
  • The element’s height

    Declaration

    Swift

    public internal(set) var height: CGFloat { get }
  • Accesses the value of the given guide, or the default value of the alignment if this guide has not been set.

    Declaration

    Swift

    public internal(set) subscript(guide: HorizontalAlignment) -> CGFloat { get set }
  • Accesses the value of the given guide, or the default value of the alignment if this guide has not been set.

    Declaration

    Swift

    public internal(set) subscript(guide: VerticalAlignment) -> CGFloat { get set }
  • Returns the explicit value of the given alignment guide in this view, or nil if no such value exists.

    Declaration

    Swift

    public subscript(explicit guide: HorizontalAlignment) -> CGFloat? { get }
  • Returns the explicit value of the given alignment guide in this view, or nil if no such value exists.

    Declaration

    Swift

    public subscript(explicit guide: VerticalAlignment) -> CGFloat? { get }