FUIStandardAutoSizingColumnFlowLayout
@MainActor
open class FUIStandardAutoSizingColumnFlowLayout : FUIBaseCollectionViewLayout<FUIStandardAutoSizingColumnSectionLayoutManager>
The FUIStandardAutoSizingColumnFlowLayout resizes collection view cell items, to lay them out according to a specified number of columns. All items per row are top-aligned, though the cell item height may vary, based upon the AutoLayout system’s height calculation for the cell.
Code usage
Assign an instance of FUIStandardAutoSizingColumnFlowLayout to your collection view.
self.collectionView.collectionViewLayout = FUICollectionViewLayout.autosizingColumnFlowImplement collectionView(_:cellForItemAt:) dataSource.
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FUIObjectCollectionViewCell.reuseIdentifier, for: indexPath) as! FUIObjectCollectionViewCell //configue cell here //... return cell }Implement following methods if you need section header/footer. You can also set headerReferenceHeight/footerReferenceHeight to apply same height for all headers/footers.
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { let view = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "Header", for: indexPath) as! FUICollectionSectionHeaderFooterView //configue header/footer view here //... return view } }
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { switch section { case 0: return CGSize(width: 40, height: 40) default: return CGSize(width: 60, height: 60) }
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { switch section { case 0: return CGSize(width: 40, height: 40) default: return CGSize(width: 60, height: 60) }
-
Undocumented
Declaration
Swift
@MainActor public var shouldApplyIdenticalCellHeight: Bool { get set } -
Whether it is a masonry layout. When it is
true,shouldApplyIdenticalCellHeightis not used.Declaration
Swift
@MainActor public var isMasonryLayout: Bool { get set } -
Order of cards: if
truethen the placement of the cards is left-most then top-most; otherwise it is top-most then left-most (Masonry Layout). WhenisMasonryLayoutisfalse, this is not used.Declaration
Swift
@MainActor public var isLeftMostOrder: Bool { get set } -
Number of columns of the layout. Default is 2. In compact mode only one column will be shown regardless of what the value is for this property. Set
isSingleColumnInCompactto false to allow multiple columns in compact mode.Declaration
Swift
@MainActor open var numberOfColumns: Int { get set } -
Indicating if there is only one column in compact mode.
Declaration
Swift
@MainActor public var isSingleColumnInCompact: Bool { get set }