Contents

layoutAttributesForInterItemGap(before:)

Returns layout attributes for the inter-item gap at the specified location in your layout.

Declaration

func layoutAttributesForInterItemGap(before indexPath: IndexPath) -> NSCollectionViewLayoutAttributes?

Parameters

  • indexPath:

    The index path of the item that follows the inter-item gap. For a gap that follows the last item in the section, set the item property to the total number of items in the section.

Return Value

A layout attributes object containing the layout information to apply to the inter-item gap, or nil if no attributes are available.

Discussion

The default implementation of this method returns nil. Subclasses can override this method to provide layout attributes for inter-item gaps. In your implementation, use the specified index path to compute the location of the gap in collection view’s content. If the gap represents a valid location, use the init(forInterItemGapBefore:) class method of NSCollectionViewLayoutAttributes to create a new layout attributes object and set the frame property to the rectangle you computed.

See Also

Providing Layout Information