RectBasedLayout
public protocol RectBasedLayout
Undocumented
-
Performing layout of given rect inside available rect. Attention: Apply layout for view frame using code as layout(rect: &view.frame,…) has side effect and called setFrame method on view.
Parameters
rect
Rect for layout
source
Available space for layout
-
layout(rect:in:)
Extension method -
apply(for:use:)
Extension methodUsed for layout
LayoutElement
entity in constrained bounds of parent element using constraints. Must call only on main thread.Declaration
Swift
func apply(for item: LayoutElement, use constraints: [ConstrainRect] = [])
Parameters
element
Element for layout
constraints
Array of tuples with rect and constraint
-
apply(for:in:use:)
Extension methodUsed for layout
LayoutElement
entity in constrained source space using constraints. Must call only on main thread.Declaration
Swift
func apply(for item: LayoutElement, in source: CGRect, use constraints: [ConstrainRect] = [])
Parameters
element
Element for layout
source
Source space
constraints
Array of tuples with rect and constraint
-
layout(rect:in:use:)
Extension methodCalculates frame of
LayoutElement
entity in constrained source space using constraints.Declaration
Swift
func layout(rect: CGRect, in sourceRect: CGRect, use constraints: [ConstrainRect] = []) -> CGRect
Parameters
element
Element for layout
constraints
Array of constraint elements
Return Value
Array of tuples with rect and constraint
-
apply(for:use:)
Extension methodUse for layout
LayoutElement
entity in constrained bounds of parent element using constraints. Must call only on main thread.Declaration
Swift
func apply(for item: LayoutElement, use constraints: [LayoutConstraintProtocol])
Parameters
element
Element for layout
constraints
Array of constraint elements
-
apply(for:in:use:)
Extension methodUse for layout
LayoutElement
entity in constrained source space using constraints. Must call only on main thread.Declaration
Swift
func apply(for item: LayoutElement, in sourceRect: CGRect, use constraints: [LayoutConstraintProtocol])
Parameters
element
Element for layout
sourceRect
Source space
constraints
Array of constraint elements
-
layout(rect:from:in:use:)
Extension methodCalculates frame of
LayoutElement
entity in constrained source space using constraints.Declaration
Swift
func layout(rect: CGRect, from item: LayoutElement, in sourceRect: CGRect, use constraints: [LayoutConstraintProtocol] = []) -> CGRect
Parameters
rect
Rect for layout
element
LayoutElement
containedrect
sourceRect
Space for layout
constraints
Array of constraint elements
Return Value
Corrected frame of layout element
-
debug(before:after:)
Extension method