Class

NSCollectionLayoutItem

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

Declaration

@interface NSCollectionLayoutItem : NSObject

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.

Schematic representation of the App Store app on iOS, showing a collection view with a compositional layout. The layout is composed of two horizontally-scrolling sections that have different layouts. The top section shows one group with one item visible onscreen, with other groups peeking in from the sides of the screen. The bottom section shows one group that's a column of three cells, each of those cells being an item. The two different types of items are highlighted and labeled as items.

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

+ itemWithLayoutSize:

Creates an item of the specified size.

+ itemWithLayoutSize:supplementaryItems:

Creates an item of the specified size with an array of supplementary items to attach to the item.

Getting an Item's Size

layoutSize

The item's size expressed in width and height dimensions.

Getting Supplementary Items

supplementaryItems

An array of the supplementary items attached to the item.

Configuring Spacing and Insets

edgeSpacing

The amount of space added around the boundaries of the item between other items and this item's container.

contentInsets

The amount of space added around the content of the item to adjust its final size after its position is computed.

Relationships

Inherits From

Conforms To

See Also

Items

NSCollectionLayoutVisibleItem

An item that's currently visible within the bounds of a section.