LayoutScheme

public struct LayoutScheme : LayoutBlockProtocol

LayoutScheme defines layout process for some layout blocks. Represented as simple set of layout blocks with the right sequence, that means currently performed block has constraints related to LayoutElement elements with corrected frame. LayoutScheme can contain other layout schemes.

  • Declaration

    Swift

    public var isActive: Bool { get }
  • Snapshot for current state without recalculating

    Declaration

    Swift

    public var currentSnapshot: LayoutSnapshotProtocol { get }
  • Undocumented

    Declaration

    Swift

    public init(blocks: [LayoutBlockProtocol])
  • Undocumented

    Declaration

    Swift

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

    Declaration

    Swift

    public func layout()
  • Calculate and apply frames layout elements.

    Declaration

    Swift

    public func layout(in sourceRect: CGRect)

    Parameters

    sourceRect

    Source space

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

    Declaration

    Swift

    public func apply(snapshot: LayoutSnapshotProtocol)

    Parameters

    snapshot

    Snapshot represented as array of frames.

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

    Declaration

    Swift

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

    Parameters

    sourceRect

    Source space for layout

    Return Value

    Snapshot contained frames layout elements

  • Method for perform layout calculation in child blocks. Does not call this method directly outside LayoutBlockProtocol object. Layout block should be insert contained LayoutElement elements 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

    LayoutElement elements with corrected frame

    Return Value

    Frame of this block

  • Undocumented

    Declaration

    Swift

    public mutating func insertLayout(block: LayoutBlockProtocol, to position: Int? = nil)
  • Undocumented

    Declaration

    Swift

    public mutating func removeInactiveBlocks()