FUIStandardAutoSizingColumnFlowLayout

open class FUIStandardAutoSizingColumnFlowLayout: UICollectionViewLayout

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. swfit self.collectionView.collectionViewLayout = FUICollectionViewLayout.autosizingColumnFlow

  2. Implement collectionView(:cellForItemAt:) dataSource. “`swfit 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. “`swift 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) } ”`

  • The spacing to use between items in the same row.

    Declaration

    Swift

    open var minimumInteritemSpacing: CGFloat = 15
  • The spacing to use between lines of items in the grid.

    Declaration

    Swift

    open var minimumLineSpacing: CGFloat = 10
  • The margins used to lay out content in a section.

    Declaration

    Swift

    open var sectionInset: UIEdgeInsets = UIEdgeInsets.zero
  • The default height to use for section headers. Implementing collectionView(_:layout:referenceSizeForHeaderInSection:) will override this property.

    Declaration

    Swift

    open var headerReferenceHeight: CGFloat = 0
  • The default height to use for section footers. Implementing collectionView(_:layout:referenceSizeForFooterInSection:) will override this property.

    Declaration

    Swift

    open var footerReferenceHeight: CGFloat = 0
  • Returns the width and height of the collection view’s contents.

    Declaration

    Swift

    open override var collectionViewContentSize: CGSize
  • Number of columns of the layout. Default is 2. Only valid in regular mode.

    Declaration

    Swift

    open var numberOfColumns = 2