LayoutTraits

public struct LayoutTraits

A heterogeneous container of traits associated with a subelement being laid out.

Generally, layout implementations will not need to use this type directly. However, elements that apply multiple traits to each subelement will use this type to store the traits, and calling add(traits:key:element:) when creating the ElementContent.

Layout implementations may access subelements’ traits during layout using the LayoutSubelement/subscript(key:) subscript. For more information, see LayoutTraitsKey.

  • An empty set of traits.

    Declaration

    Swift

    public static let empty: LayoutTraits
  • Creates a set of traits containing the specified key and value.

    Declaration

    Swift

    public init<K>(key: K.Type, value: K.Value) where K : LayoutTraitsKey
  • Gets or sets a trait value by its key.

    Declaration

    Swift

    public subscript<Key>(key: Key.Type) -> Key.Value where Key : LayoutTraitsKey { get set }
  • Returns a copy of this set of traits with the specified key and value set.

    Declaration

    Swift

    public func setting<Key>(key: Key.Type, to value: Key.Value) -> LayoutTraits where Key : LayoutTraitsKey