FUIStandardAutoSizingColumnFlowLayout

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

  1. Assign an instance of FUIStandardAutoSizingColumnFlowLayout to your collection view.

    self.collectionView.collectionViewLayout = FUICollectionViewLayout.autosizingColumnFlow
    
  2. Implement 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
    }
    
  3. 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

    public var shouldApplyIdenticalCellHeight: Bool { get set }
  • Whether it is a masonry layout. When it is true, shouldApplyIdenticalCellHeight is not used.

    Declaration

    Swift

    public var isMasonryLayout: Bool { get set }
  • Order of cards: if true then the placement of the cards is left-most then top-most; otherwise it is top-most then left-most (Masonry Layout). When isMasonryLayout is false, this is not used.

    Declaration

    Swift

    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 isSingleColumnInCompact to false to allow multiple columns in compact mode.

    Declaration

    Swift

    open var numberOfColumns: Int { get set }
  • Indicating if there is only one column in compact mode.

    Declaration

    Swift

    public var isSingleColumnInCompact: Bool { get set }