UICollectionViewFlowLayout

extension UICollectionViewFlowLayout
  • Returns a UICollectionViewFlowLayout initialized with the provided scroll direction, item spacing, line spacing, and section inset.

    Declaration

    Swift

    public convenience init(
        scrollDirection: UICollectionView.ScrollDirection,
        itemSpacing: CGFloat = 10,
        lineSpacing: CGFloat = 10,
        sectionInset: UIEdgeInsets = .zero)

    Parameters

    scrollDirection

    The scroll direction of the layout.

    itemSpacing

    The minimum spacing to use between items in the same row (optional, defaults to 10).

    lineSpacing

    The minimum spacing to use between lines of items in the grid (optional, defaults to 10).

    sectionInset

    The margins used to lay out content in a section (optional, defaults to .zero).

    Return Value

    A UICollectionViewFlowLayout initialized with the provided scroll direction, item spacing, line spacing, and section inset.

  • Creates a vertical UICollectionViewFlowLayout.

    Declaration

    Swift

    public static func vertical(itemSpacing: CGFloat = 10, lineSpacing: CGFloat = 10, sectionInset: UIEdgeInsets = .zero) -> UICollectionViewFlowLayout

    Parameters

    itemSpacing

    The minimum spacing between items in the same row (optional, defaults to 10).

    lineSpacing

    The minimum spacing between successive rows (optional, defaults to 10).

    sectionInset

    The spacing at the outer edges of the section (optional, defaults to .zero).

    Return Value

    A vertical UICollectionViewFlowLayout with the specified item spacing, line spacing, and section inset.

  • Creates a horizontal UICollectionViewFlowLayout.

    Declaration

    Swift

    public static func horizontal(itemSpacing: CGFloat = 10, lineSpacing: CGFloat = 10, sectionInset: UIEdgeInsets = .zero) -> UICollectionViewFlowLayout

    Parameters

    itemSpacing

    The minimum spacing between items in the same column (optional, defaults to 10).

    lineSpacing

    The minimum spacing between successive columns (optional, defaults to 10).

    sectionInset

    The spacing at the outer edges of the section (optional, defaults to .zero).

    Return Value

    A vertical UICollectionViewFlowLayout with the specified item spacing, line spacing, and section inset.