ColumnsLayout

public struct ColumnsLayout: Layout

A Layout that arranges its subviews in columns

  • The spacing between the columns or nil to use the default

    Declaration

    Swift

    public var columnSpacing: Double?
  • The spacing between the subviews in the column row ornil to use the default

    Declaration

    Swift

    public var rowSpacing: Double?
  • Init the ColumnLayout

    Declaration

    Swift

    public init(
        columnSpacing: Double? = nil,
        rowSpacing: Double? = nil
    )

    Parameters

    columnSpacing

    The spacing between the columns or nil to use the default

    rowSpacing

    The spacing between the subviews in the column row ornil to use the default

  • The layout properties

    Declaration

    Swift

    public static var layoutProperties: LayoutProperties
  • A shared computation between sizeThatFits and placeSubviews.

    See more

    Declaration

    Swift

    public struct Cache
  • Make a cache

    Declaration

    Swift

    public func makeCache(subviews: Subviews) -> Cache

    Parameters

    subviews

    The subviews

    Return Value

    The cache

  • Update the cache

    Declaration

    Swift

    public func updateCache(_ cache: inout Cache, subviews: Subviews)

    Parameters

    cache

    The cache

    subviews

    The subviews

  • Returns the size of the composite view, given a proposed size and the view’s subviews

    Note

    Protocol requirement

    Declaration

    Swift

    public func sizeThatFits(
        proposal: ProposedViewSize,
        subviews: Subviews,
        cache: inout Cache
    ) -> CGSize

    Parameters

    proposal

    A size proposal for the container

    subviews

    A collection of proxies that represent the views that the container arranges

    cache

    Optional storage for calculated data

    Return Value

    A size that indicates how much space the container needs to arrange its subviews

  • Assigns positions to each of the layout’s subviews

    Note

    Protocol requirement

    Declaration

    Swift

    public func placeSubviews(
        in bounds: CGRect,
        proposal: ProposedViewSize,
        subviews: Subviews,
        cache: inout Cache
    )

    Parameters

    bounds

    The region that the container view’s parent allocates to the container view, specified in the parent’s coordinate space

    proposal

    The size proposal from which the container generated the size that the parent used to create the bounds parameter

    subviews

    A collection of proxies that represent the views that the container arranges

    cache

    Optional storage for calculated data

  • The structure of a column

    See more

    Declaration

    Swift

    struct Column
  • The structure of an element

    See more

    Declaration

    Swift

    struct Element
  • Arrange columns

    Declaration

    Swift

    private func arrangeColumns(
        proposal: ProposedViewSize,
        subviews: Subviews,
        cache: inout Cache
    ) -> [Column]

    Parameters

    proposal

    The proposed view size

    subviews

    The subviews

    cache

    The cache

    Return Value

    Thew columns

  • Compute hash

    Declaration

    Swift

    private func computeHash(proposal: ProposedViewSize, sizes: [CGSize]) -> Int

    Parameters

    proposal

    The proposed view size

    sizes

    The array of sizes

    Return Value

    A hash as Int value

  • Calculate the minimum size

    Declaration

    Swift

    private func minSize(subviews: Subviews) -> CGSize

    Parameters

    subviews

    The subviews

    Return Value

    The size

  • Calculate the column spacing

    Declaration

    Swift

    private func columnSpacing(_ lhs: LayoutSubview, _ rhs: LayoutSubview) -> Double

    Parameters

    lhs

    The left layout subview

    rhs

    The right layout subview

    Return Value

    The spacing as Double

  • Calculate the row spacing

    Declaration

    Swift

    private func rowSpacing(_ lhs: LayoutSubview, _ rhs: LayoutSubview) -> Double

    Parameters

    lhs

    The left layout subview

    rhs

    The right layout subview

    Return Value

    The spacing as Double