StackLayoutScheme

public struct StackLayoutScheme : LayoutBlockProtocol

Defines layout for arranged items

  • Flag, defines that block will be used for layout

    Declaration

    Swift

    public var isActive: Bool { get }
  • Designed initializer

    Declaration

    Swift

    public init(items: @escaping () -> [LayoutElement])

    Parameters

    items

    Closure provides items

  • Undocumented

    Declaration

    Swift

    public var axis: RectAxis { get set }
  • Undocumented

    Declaration

    Swift

    public var spacing: StackDistribution.Spacing { get set }
  • Undocumented

    Declaration

    Swift

    public var alignment: StackDistribution.Alignment { get set }
  • Undocumented

    Declaration

    Swift

    public var filling: StackDistribution.Filling { get set }
  • Undocumented

    Declaration

    Swift

    public var direction: StackDistribution.Direction { get set }

LayoutBlockProtocol

  • Snapshot for current state without recalculating

    Declaration

    Swift

    public var currentSnapshot: LayoutSnapshotProtocol { get }
  • Undocumented

    Declaration

    Swift

    public var currentRect: CGRect { get }
  • Calculate and apply frames layout items. Should be call when parent LayoutItem item has corrected bounds. Else result unexpected.

    Declaration

    Swift

    public func layout()
  • Calculate and apply frames layout items in custom space.

    Declaration

    Swift

    public func layout(in sourceRect: CGRect)

    Parameters

    sourceRect

    Source space

  • Applying frames from snapshot to LayoutItem items in this block. Snapshot array should be ordered such to match LayoutItem items sequence.

    Declaration

    Swift

    public func apply(snapshot: LayoutSnapshotProtocol)

    Parameters

    snapshot

    Snapshot represented as array of frames.

  • Returns snapshot for all LayoutItem items in block. Attention: in during calculating snapshot frames of layout items must not changed.

    Declaration

    Swift

    public func snapshot(for sourceRect: CGRect) -> LayoutSnapshotProtocol

    Parameters

    sourceRect

    Source space for layout

    Return Value

    Snapshot contained frames layout items

  • Method for perform layout calculation in child blocks. Does not call this method directly outside LayoutBlockProtocol object. Layout block should be insert contained LayoutItem items to completedRects

    Declaration

    Swift

    public func snapshot(for sourceRect: CGRect, completedRects: inout [(AnyObject, CGRect)]) -> LayoutSnapshotProtocol

    Parameters

    sourceRect

    Source space for layout. For not top level blocks rect should be define available bounds of block

    completedRects

    LayoutItem items with corrected frame

    Return Value

    Frame of this block