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

# NSCollectionViewGridLayout

A layout that displays a single section of items in a row and column grid.

```
class NSCollectionViewGridLayout
```

## Overview

The [`NSCollectionViewGridLayout`](/documentation/AppKit/NSCollectionViewGridLayout) object provides the same layout behavior offered by the [`NSCollectionView`](/documentation/AppKit/NSCollectionView) class prior to macOS 10.11, and you can use it in cases where you want to maintain the old appearance while still taking advantage of newer collection view features.

### Configuring a Collection View to Use a Grid Layout

You can configure a collection view to use a grid layout object programmatically or at design time:

- At design time, set the Layout attribute of your collection view to Grid.
- Create an `NSCollectionViewGridLayout` object programmatically and assign it to the collection view’s [`collectionViewLayout`](/documentation/AppKit/NSCollectionView/collectionViewLayout) property.

A grid layout displays only items and does not display supplementary views or decoration views. Use the properties of this class to configure the number of rows and columns in the grid. You can also use these properties to configure the spacing between items and the minimum sizes.

## Topics

### Specifying the Grid Parameters

[`maximumNumberOfRows`](/documentation/AppKit/NSCollectionViewGridLayout/maximumNumberOfRows)

The maximum number of rows to display in the collection view’s visible area.

[`maximumNumberOfColumns`](/documentation/AppKit/NSCollectionViewGridLayout/maximumNumberOfColumns)

The maximum number of columns to display in the collection view’s visible area.

[`minimumItemSize`](/documentation/AppKit/NSCollectionViewGridLayout/minimumItemSize)

The smallest allowable size for an item’s view.

[`maximumItemSize`](/documentation/AppKit/NSCollectionViewGridLayout/maximumItemSize)

The largest allowable size for an item’s view.

### Specifying the Grid Layout Attributes

[`minimumInteritemSpacing`](/documentation/AppKit/NSCollectionViewGridLayout/minimumInteritemSpacing)

The minimum spacing (in points) to use between items in the same row or column.

[`minimumLineSpacing`](/documentation/AppKit/NSCollectionViewGridLayout/minimumLineSpacing)

The minimum spacing (in points) to use between rows or columns.

[`margins`](/documentation/AppKit/NSCollectionViewGridLayout/margins)

The amount of empty space (in points) around the grid’s content.

### Specifying the Grid Background Color

[`backgroundColors`](/documentation/AppKit/NSCollectionViewGridLayout/backgroundColors)

The array of background colors to use when drawing the grid.



---

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)