ColumnsLayout
struct ColumnsLayout: Layout
A Layout that arranges its subviews in columns
-
The spacing between the columns or
nilto use the defaultDeclaration
Swift
var columnSpacing: Double? -
The spacing between the subviews in the column row or
nilto use the defaultDeclaration
Swift
var rowSpacing: Double? -
The layout properties
Declaration
Swift
static var layoutProperties: LayoutProperties -
A shared computation between
See moresizeThatFitsandplaceSubviews.Declaration
Swift
struct Cache -
Make a cache
Declaration
Swift
func makeCache(subviews: Subviews) -> CacheParameters
subviewsThe subviews
Return Value
The cache
-
Update the cache
Declaration
Swift
func updateCache(_ cache: inout Cache, subviews: Subviews)Parameters
cacheThe cache
subviewsThe subviews
-
Returns the size of the composite view, given a proposed size and the view’s subviews
Note
Protocol requirementDeclaration
Swift
func sizeThatFits( proposal: ProposedViewSize, subviews: Subviews, cache: inout Cache ) -> CGSizeParameters
proposalA size proposal for the container
subviewsA collection of proxies that represent the views that the container arranges
cacheOptional storage for calculated data
Return Value
A size that indicates how much space the container needs to arrange its subviews
-
Assigns positions to each of the layout’s subviews
Note
Protocol requirementDeclaration
Swift
func placeSubviews( in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout Cache )Parameters
boundsThe region that the container view’s parent allocates to the container view, specified in the parent’s coordinate space
proposalThe size proposal from which the container generated the size that the parent used to create the bounds parameter
subviewsA collection of proxies that represent the views that the container arranges
cacheOptional storage for calculated data
-
The structure of a column
See moreDeclaration
Swift
struct Column -
The structure of an element
See moreDeclaration
Swift
struct Element -
Arrange columns
Declaration
Parameters
proposalThe proposed view size
subviewsThe subviews
cacheThe cache
Return Value
Thew columns
-
Compute hash
Declaration
Swift
private func computeHash(proposal: ProposedViewSize, sizes: [CGSize]) -> IntParameters
proposalThe proposed view size
sizesThe array of sizes
Return Value
A hash as
Intvalue -
Calculate the minimum size
Declaration
Swift
private func minSize(subviews: Subviews) -> CGSizeParameters
subviewsThe subviews
Return Value
The size
-
Calculate the column spacing
Declaration
Swift
private func columnSpacing(_ lhs: LayoutSubview, _ rhs: LayoutSubview) -> DoubleParameters
lhsThe left layout subview
rhsThe right layout subview
Return Value
The spacing as
Double -
Calculate the row spacing
Declaration
Swift
private func rowSpacing(_ lhs: LayoutSubview, _ rhs: LayoutSubview) -> DoubleParameters
lhsThe left layout subview
rhsThe right layout subview
Return Value
The spacing as
Double
View on GitHub