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
Assign an instance of FUIStandardAutoSizingColumnFlowLayout to your collection view.
self.collectionView.collectionViewLayout = FUICollectionViewLayout.autosizingColumnFlow
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 }
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) }
-
The spacing to use between items in the same row.
Declaration
Swift
open var minimumInteritemSpacing: CGFloat
-
The spacing to use between lines of items in the grid.
Declaration
Swift
open var minimumLineSpacing: CGFloat
-
The margins used to lay out content in a section.
Declaration
Swift
open var sectionInset: UIEdgeInsets
-
The default height to use for section headers. Implementing collectionView(_:layout:referenceSizeForHeaderInSection:) will override this property.
Declaration
Swift
open var headerReferenceHeight: CGFloat
-
The default height to use for section footers. Implementing collectionView(_:layout:referenceSizeForFooterInSection:) will override this property.
Declaration
Swift
open var footerReferenceHeight: CGFloat
-
Returns the width and height of the collection view’s contents.
Declaration
Swift
open override var collectionViewContentSize: CGSize { get }
-
Number of columns of the layout. Default is 2. Only valid in regular 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 }