<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSCollectionViewDelegateFlowLayout",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSCollectionViewDelegateFlowLayout"
  },
  "title" : "NSCollectionViewDelegateFlowLayout"
}
-->

# NSCollectionViewDelegateFlowLayout

A set of methods that a delegate implements to provide layout information to a flow layout object in a collection view.

```
protocol NSCollectionViewDelegateFlowLayout : NSCollectionViewDelegate
```

## Overview

Implement the methods of this protocol when you want to customize the layout behavior and perhaps return different values for different items or sections.

All of the methods in this protocol are optional, so you can implement only the methods you need to achieve the desired layout. If you do not implement a particular method, the flow layout object obtains default values from its own properties and applies them uniformly. Implement your methods in the object you assign to the [`delegate`](/documentation/AppKit/NSCollectionView/delegate) property of the collection view itself.

## Topics

### Getting the Size of Items

[`collectionView(_:layout:sizeForItemAt:)`](/documentation/AppKit/NSCollectionViewDelegateFlowLayout/collectionView(_:layout:sizeForItemAt:))

Asks the delegate for the size of the specified item.

### Getting the Section Spacing

[`collectionView(_:layout:insetForSectionAt:)`](/documentation/AppKit/NSCollectionViewDelegateFlowLayout/collectionView(_:layout:insetForSectionAt:))

Asks the delegate for the margins to apply to content in the specified section.

[`collectionView(_:layout:minimumLineSpacingForSectionAt:)`](/documentation/AppKit/NSCollectionViewDelegateFlowLayout/collectionView(_:layout:minimumLineSpacingForSectionAt:))

Asks the delegate for the spacing between successive rows or columns of a section.

[`collectionView(_:layout:minimumInteritemSpacingForSectionAt:)`](/documentation/AppKit/NSCollectionViewDelegateFlowLayout/collectionView(_:layout:minimumInteritemSpacingForSectionAt:))

Asks the delegate for the spacing between successive items of a single row or column.

### Getting the Header and Footer Sizes

[`collectionView(_:layout:referenceSizeForHeaderInSection:)`](/documentation/AppKit/NSCollectionViewDelegateFlowLayout/collectionView(_:layout:referenceSizeForHeaderInSection:))

Asks the delegate for the size of the header view in the specified section.

[`collectionView(_:layout:referenceSizeForFooterInSection:)`](/documentation/AppKit/NSCollectionViewDelegateFlowLayout/collectionView(_:layout:referenceSizeForFooterInSection:))

Asks the delegate for the size of the footer view in the specified section.



---

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)