Contents

NSCollectionLayoutGroup

A container for a set of items that lays out the items along a path.

Declaration

@MainActor class NSCollectionLayoutGroup

Overview

Groups determine how the items in a collection view lay out in relation to each other. A group might lay out its items in a horizontal row, a vertical column, or a custom arrangement. A group determines the rules for how items are rendered in relation to each other, but in itself doesn’t render any content.

For example, in the Photos app, a group of items is a row of photos. In the App Store app, a group might be a single column of cells (items) arranged in a vertical column.

[Image]

Each group specifies its own size in terms of a width dimension and a height dimension. Groups 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.

Because a group is a subclass of NSCollectionLayoutItem, it behaves like an item. You can combine a group with other items and groups into more complex layouts.

[Image]

After you configure a group, you must initialize a section (NSCollectionLayoutSection) of your collection view layout with that group.

Topics

Creating a horizontal group

Creating a vertical group

Creating a custom group

Getting the group’s items

Configuring group spacing

Debugging group layout

Deprecated

See Also

Components