subscript(_:)
Gets the value for the subview that’s associated with the specified key.
Declaration
subscript<K>(key: K.Type) -> K.Value where K : LayoutValueKey { get }Overview
If you define a custom layout value using LayoutValueKey, you can read the key’s associated value for a given subview in a layout container by indexing the container’s subviews with the key type. For example, if you define a Flexibility key type, you can put the associated values of all the layout’s subviews into an array:
let flexibilities = subviews.map { subview in
subview[Flexibility.self]
}For more information about creating a custom layout, see Layout.