layoutAttributesForItem(at:)
Retrieves layout information for an item at the specified index path with a corresponding cell.
Declaration
func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes?Parameters
- indexPath:
The index path of the item.
Return Value
A layout attributes object containing the information to apply to the item’s cell.
Discussion
Subclasses must override this method and use it to return layout information for items in the collection view. You use this method to provide layout information only for items that have a corresponding cell. Do not use it for supplementary views or decoration views.
See Also
Providing layout attributes
layoutAttributesClassprepare()layoutAttributesForElements(in:)layoutAttributesForInteractivelyMovingItem(at:withTargetPosition:)layoutAttributesForSupplementaryView(ofKind:at:)layoutAttributesForDecorationView(ofKind:at:)targetContentOffset(forProposedContentOffset:)targetContentOffset(forProposedContentOffset:withScrollingVelocity:)