---
title: UICollectionViewFlowLayout
framework: uikit
role: symbol
role_heading: Class
path: uikit/uicollectionviewflowlayout
---

# UICollectionViewFlowLayout

A layout object that organizes items into a grid with optional header and footer views for each section.

## Declaration

```swift
@MainActor class UICollectionViewFlowLayout
```

## Overview

Overview A flow layout is a type of collection view layout. Items in the collection view flow from one row or column (depending on the scrolling direction) to the next, with each row containing as many cells as will fit. Cells can be the same sizes or different sizes. A flow layout works with the collection view’s delegate object to determine the size of items, headers, and footers in each section and grid. That delegate object must conform to the UICollectionViewDelegateFlowLayout protocol. Use of the delegate allows you to adjust layout information dynamically. For example, you use a delegate object to specify different sizes for items in the grid. If you don’t provide a delegate, the flow layout uses the default values you set in the properties of this class. Flow layouts lay out their content using a fixed distance in one direction and a scrollable distance in the other. For example, in a vertically scrolling grid, the width of the grid content is constrained to the width of the corresponding collection view while the height of the content adjusts dynamically to match the number of sections and items in the grid. The layout scrolls vertically by default, but you can configure the scrolling direction using the scrollDirection property. Each section in a flow layout can have its own custom header and footer. To configure the header or footer for a view, configure the size of the header or footer to be non-zero. Implement the appropriate delegate methods or assign appropriate values to the headerReferenceSize and footerReferenceSize properties. If the header or footer size is 0, the corresponding view isn’t added to the collection view.

## Topics

### Configuring the flow layout

- [UICollectionViewDelegateFlowLayout](uikit/uicollectionviewdelegateflowlayout.md)

### Configuring the scroll direction

- [scrollDirection](uikit/uicollectionviewflowlayout/scrolldirection.md)
- [UICollectionView.ScrollDirection](uikit/uicollectionview/scrolldirection.md)

### Configuring item spacing

- [minimumLineSpacing](uikit/uicollectionviewflowlayout/minimumlinespacing.md)
- [minimumInteritemSpacing](uikit/uicollectionviewflowlayout/minimuminteritemspacing.md)
- [itemSize](uikit/uicollectionviewflowlayout/itemsize.md)
- [estimatedItemSize](uikit/uicollectionviewflowlayout/estimateditemsize.md)
- [automaticSize](uikit/uicollectionviewflowlayout/automaticsize.md)
- [sectionInset](uikit/uicollectionviewflowlayout/sectioninset.md)
- [sectionInsetReference](uikit/uicollectionviewflowlayout/sectioninsetreference-swift.property.md)
- [UICollectionViewFlowLayout.SectionInsetReference](uikit/uicollectionviewflowlayout/sectioninsetreference-swift.enum.md)

### Configuring headers and footers

- [headerReferenceSize](uikit/uicollectionviewflowlayout/headerreferencesize.md)
- [footerReferenceSize](uikit/uicollectionviewflowlayout/footerreferencesize.md)
- [Flow layout supplementary views](uikit/flow-layout-supplementary-views.md)

### Pinning headers and footers

- [sectionHeadersPinToVisibleBounds](uikit/uicollectionviewflowlayout/sectionheaderspintovisiblebounds.md)
- [sectionFootersPinToVisibleBounds](uikit/uicollectionviewflowlayout/sectionfooterspintovisiblebounds.md)

## Relationships

### Inherits From

- [UICollectionViewLayout](uikit/uicollectionviewlayout.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Manual layouts

- [Customizing collection view layouts](uikit/customizing-collection-view-layouts.md)
- [UICollectionViewLayout](uikit/uicollectionviewlayout.md)
- [UICollectionViewTransitionLayout](uikit/uicollectionviewtransitionlayout.md)
- [UICollectionViewLayoutAttributes](uikit/uicollectionviewlayoutattributes.md)
- [UICollectionViewFlowLayoutInvalidationContext](uikit/uicollectionviewflowlayoutinvalidationcontext.md)
