Instance Method

layoutAttributesForElementsInRect:

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

Declaration

- (NSArray<__kindof NSCollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(NSRect)rect;

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 layoutAttributesForItemAtIndexPath:, layoutAttributesForSupplementaryViewOfKind:atIndexPath:, and layoutAttributesForDecorationViewOfKind:atIndexPath: methods to create new layout attribute objects.

See Also

Providing Layout Information

layoutAttributesClass

Returns the class to use for layout attribute objects

- prepareLayout

Prepares the layout object to begin laying out content.

collectionViewContentSize

The width and height of the collection view’s contents.

- layoutAttributesForItemAtIndexPath:

Returns the layout attributes for the item at the specified index path.

- layoutAttributesForSupplementaryViewOfKind:atIndexPath:

Returns the layout attributes of the supplementary view at the specified location in your layout.

- layoutAttributesForDecorationViewOfKind:atIndexPath:

Returns the layout attributes of the decoration view at the specified location in your layout.

- layoutAttributesForDropTargetAtPoint:

Returns layout attributes for the drop target at the specified point.

- layoutAttributesForInterItemGapBeforeIndexPath:

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

- targetContentOffsetForProposedContentOffset:

Returns the offset value to use after an animated layout update or change.

- targetContentOffsetForProposedContentOffset:withScrollingVelocity:

Returns the offset value to use for the collection view’s content at the end of scrolling.