LayoutBlock
public final class LayoutBlock<Item> : LayoutBlockProtocol where Item : LayoutElement
Makes full layout for LayoutElement
entity. Contains main layout, related anchor constrains and element for layout.
-
Undocumented
Declaration
Swift
public private(set) weak var item: Item?
-
Declaration
Swift
public var isActive: Bool { get }
-
Undocumented
Declaration
Swift
public func setItem(_ item: Item?)
-
Undocumented
Declaration
Swift
public func setLayout(_ layout: RectBasedLayout)
-
Undocumented
Declaration
Swift
public func setConstraints(_ constraints: [LayoutConstraintProtocol])
-
Snapshot for current state without recalculating
Declaration
Swift
public var currentSnapshot: LayoutSnapshotProtocol { get }
-
Undocumented
Declaration
Swift
public var currentRect: CGRect { get }
-
Undocumented
Declaration
Swift
public init(element: Item?, layout: RectBasedLayout, constraints: [LayoutConstraintProtocol] = [])
-
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 in custom space.
Declaration
Swift
public func layout(in sourceRect: CGRect)
Parameters
sourceRect
Source space
-
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 containedLayoutElement
elements to completedRectsDeclaration
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 frameReturn Value
Frame of this block
-
Applying frames from snapshot to
LayoutElement
elements in this block. Snapshot array should be ordered such to matchLayoutElement
elements sequence.Declaration
Swift
public func apply(snapshot: LayoutSnapshotProtocol)
Parameters
snapshot
Snapshot represented as array of frames.