layoutAttributesForDecorationView(ofKind:at:)
Returns the layout attributes of the decoration view at the specified location in your layout.
Declaration
func layoutAttributesForDecorationView(ofKind elementKind: NSCollectionView.DecorationElementKind, at indexPath: IndexPath) -> NSCollectionViewLayoutAttributes?Parameters
- elementKind:
A string that identifies the type of the decoration view. Use this string to differentiate the decoration views in a given section.
- indexPath:
The index path of the decoration view. Use this parameter to determine which section contains the decoration view.
Return Value
A layout attributes object containing the layout information to apply to the decoration view.
Discussion
If your layout includes decoration views, you must override this method. In your implementation, create an instance of the appropriate layout attributes class and fill the resulting object with the layout information for the corresponding decoration view. You define the supported decoration views by assigning each one a string that identifies its kind. Use the elementKind and indexPath properties to identify the specific decoration view whose attributes were requested.
You can call this method from other layout-related methods when you want to retrieve layout information for decoration views. Call this method only for decoration views. Do not call it to retrieve layout attributes for items or supplementary views.
See Also
Providing Layout Information
layoutAttributesClassprepare()collectionViewContentSizelayoutAttributesForElements(in:)layoutAttributesForItem(at:)layoutAttributesForSupplementaryView(ofKind:at:)layoutAttributesForDropTarget(at:)layoutAttributesForInterItemGap(before:)targetContentOffset(forProposedContentOffset:)targetContentOffset(forProposedContentOffset:withScrollingVelocity:)