Contents

layoutAttributesForElements(in:)

Returns the layout attribute objects for all items and views in the specified rectangle.

Declaration

func layoutAttributesForElements(in rect: NSRect) -> [NSCollectionViewLayoutAttributes]

Parameters

  • rect:

    The rectangle (specified in the collection view’s coordinate system) containing the target views.

Return Value

An array of layout attribute objects containing the layout information for the enclosed items and views.

Discussion

Subclasses must override this method. In your implementation, return layout attributes for all items, supplementary views, and decoration views that intersect the specified rectangle.

For each element, always return a layout object of the appropriate type (item, supplementary, or decoration). The collection view differentiates between attributes for items, supplementary views, and decoration views and uses the differences to decide how to create and manage the corresponding views. Use the layoutAttributesForItem(at:), layoutAttributesForSupplementaryView(ofKind:at:), and layoutAttributesForDecorationView(ofKind:at:) methods to create new layout attribute objects.

See Also

Providing Layout Information