Class

NSCollectionLayoutSpacing

An object that defines the space between or around items in a collection view.

Declaration

@interface NSCollectionLayoutSpacing : NSObject

Overview

In a collection view layout, you use a spacing object to specify both the amount of space and the way in which it's calculated.

You can express spacing using fixed or flexible spacing.

Use fixed spacing to provide an exact amount of space. For example, the following code creates exactly 200 points of space between the items in the group.

group.interItemSpacing = .fixed(200.0)

Use flexible spacing to provide a minimum amount of space that can grow as more space becomes available. For example, the following code creates at least 200 points of space between the items in the group. As more space becomes available, items are respaced evenly in the additional space.

group.interItemSpacing = .flexible(200.0)

Topics

Creating Spacing

+ fixedSpacing:

Creates a space equivalent to the specified number of points.

+ flexibleSpacing:

Creates a space equivalent to or greater than the specified number of points, depending on the available space.

Getting the Spacing Value

spacing

The floating-point value of the space.

Getting the Spacing Type

isFixedSpacing

A Boolean value that indicates whether the space is fixed to a specific number of points.

isFlexibleSpacing

A Boolean value that indicates whether the space is flexible.

Relationships

Inherits From

Conforms To

See Also

Size and Spacing

NSCollectionLayoutDimension

An individual dimension of an item's size (width or height) in a collection view.

NSCollectionLayoutSize

The width and the height of an item in a collection view.

NSCollectionLayoutEdgeSpacing

An object that defines the space around the edges of items in a collection view.

NSCollectionLayoutContainer

A protocol used to provide information about the size and content insets of a layout's container.