Contents

NSCollectionLayoutItem

The most basic component of a collection view’s layout.

Declaration

@MainActor class NSCollectionLayoutItem

Overview

An item is a blueprint for how to size, space, and arrange an individual piece of content in your collection view. An item represents a single view that’s rendered onscreen. Generally, an item is a cell, but items can be supplementary views like headers, footers, and other decorations.

For example, in the Photos app, an item might represent a single photo. In the App Store app, an item might be a cell displaying information about an individual app in a list of featured apps, such as the app icon, app name, tagline, and download button.

[Image]

Each item specifies its own size in terms of a width dimension and a height dimension. Items can express their dimensions relative to their container, as an absolute value, or as an estimated value that might change at runtime, like in response to a change in system font size. For more information, see NSCollectionLayoutDimension.

You combine items into groups that determine how those items are arranged in relation to each other. For more information, see NSCollectionLayoutGroup.

Topics

Creating an item

Getting an item’s size

Getting supplementary items

Configuring spacing and insets

See Also

Components