<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UICollectionViewFlowLayout",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UICollectionViewFlowLayout"
  },
  "title" : "UICollectionViewFlowLayout"
}
-->

# UICollectionViewFlowLayout

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

```
@MainActor class UICollectionViewFlowLayout
```

## 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`](/documentation/UIKit/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`](/documentation/UIKit/UICollectionViewFlowLayout/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`](/documentation/UIKit/UICollectionViewFlowLayout/headerReferenceSize) and [`footerReferenceSize`](/documentation/UIKit/UICollectionViewFlowLayout/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`](/documentation/UIKit/UICollectionViewDelegateFlowLayout)

The methods that let you coordinate with a flow layout object to implement a grid-based layout.

### Configuring the scroll direction

[`scrollDirection`](/documentation/UIKit/UICollectionViewFlowLayout/scrollDirection)

The scroll direction of the grid.

[`UICollectionView.ScrollDirection`](/documentation/UIKit/UICollectionView/ScrollDirection)

Constants that indicate the direction of scrolling for the layout.

### Configuring item spacing

[`minimumLineSpacing`](/documentation/UIKit/UICollectionViewFlowLayout/minimumLineSpacing)

The minimum spacing to use between lines of items in the grid.

[`minimumInteritemSpacing`](/documentation/UIKit/UICollectionViewFlowLayout/minimumInteritemSpacing)

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

[`itemSize`](/documentation/UIKit/UICollectionViewFlowLayout/itemSize)

The default size to use for cells.

[`estimatedItemSize`](/documentation/UIKit/UICollectionViewFlowLayout/estimatedItemSize)

The estimated size of cells in the collection view.

[`automaticSize`](/documentation/UIKit/UICollectionViewFlowLayout/automaticSize)

A placeholder size for self-sizing cells.

[`sectionInset`](/documentation/UIKit/UICollectionViewFlowLayout/sectionInset)

The margins used to lay out content in a section.

[`sectionInsetReference`](/documentation/UIKit/UICollectionViewFlowLayout/sectionInsetReference-swift.property)

The boundary that section insets are defined in relation to.

[`UICollectionViewFlowLayout.SectionInsetReference`](/documentation/UIKit/UICollectionViewFlowLayout/SectionInsetReference-swift.enum)

Constants that describe the reference point of the section insets.

### Configuring headers and footers

[`headerReferenceSize`](/documentation/UIKit/UICollectionViewFlowLayout/headerReferenceSize)

The default sizes to use for section headers.

[`footerReferenceSize`](/documentation/UIKit/UICollectionViewFlowLayout/footerReferenceSize)

The default sizes to use for section footers.

[Flow layout supplementary views](/documentation/UIKit/flow-layout-supplementary-views)

Constants that specify the types of supplementary views that can be presented using a flow layout.

### Pinning headers and footers

[`sectionHeadersPinToVisibleBounds`](/documentation/UIKit/UICollectionViewFlowLayout/sectionHeadersPinToVisibleBounds)

A Boolean value that indicates whether headers pin to the top of the collection view bounds during scrolling.

[`sectionFootersPinToVisibleBounds`](/documentation/UIKit/UICollectionViewFlowLayout/sectionFootersPinToVisibleBounds)

A Boolean value that indicates whether footers pin to the bottom of the collection view bounds during scrolling.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)
