LayoutBlockProtocol
public protocol LayoutBlockProtocol
Defines general methods for any layout block
-
Flag, defines that block will be used for layout
Declaration
Swift
var isActive: Bool { get } -
Snapshot for current state without recalculating
Declaration
Swift
var currentSnapshot: LayoutSnapshotProtocol { get } -
Undocumented
Declaration
Swift
var currentRect: CGRect { get } -
Calculate and apply frames layout items. Should be call when parent
LayoutElementelement has corrected bounds. Else result unexpected.Declaration
Swift
func layout() -
Calculate and apply frames layout items in custom space.
Declaration
Swift
func layout(in sourceRect: CGRect)Parameters
sourceRectSource space
-
Returns snapshot for all
LayoutElementitems in block. Attention: in during calculating snapshot frames of layout items must not changed.Declaration
Swift
func snapshot(for sourceRect: CGRect) -> LayoutSnapshotProtocolParameters
sourceRectSource space for layout
Return Value
Snapshot that contains frames layout items
-
Returns snapshot for all
LayoutElementitems in block. Does not call this method directly outsideLayoutBlockProtocolobject. Method implementation should operatecompletedRectswith allLayoutElementitems, that has been used to constrain this and child blocks.Declaration
Swift
func snapshot(for sourceRect: CGRect, completedRects: inout [(AnyObject, CGRect)]) -> LayoutSnapshotProtocolParameters
sourceRectSource space for layout. For not top level blocks rect should define the available bounds of block
completedRectsLayoutElementitems with corrected frameReturn Value
Snapshot that contains frames layout items
-
Applying frames from snapshot to
LayoutElementitems in this block. Snapshot array should be ordered such to matchLayoutElementitems sequence.Declaration
Swift
func apply(snapshot: LayoutSnapshotProtocol)Parameters
snapshotSnapshot represented as array of frames.
-
snapshot(for:constrainRects:)Extension methodReturns snapshot for all
LayoutElementitems in block. Use this method when you need to get snapshot for block, that has been constrained byLayoutElementitems, that is not included to this block. For example: block constrained by super element and you need to get size of block.Declaration
Swift
func snapshot(for sourceRect: CGRect, constrainRects: [(AnyObject, CGRect)]) -> LayoutSnapshotProtocolParameters
sourceRectSource space for layout.
constrainRectsLayoutElementitems, that not included to block, but use for constraining.Return Value
Snapshot that contains frames layout items
LayoutBlockProtocol Protocol Reference