supplementaryView(forElementKind:at:)
Returns the supplementary view associated with the specified index path.
Declaration
func supplementaryView(forElementKind elementKind: NSCollectionView.SupplementaryElementKind, at indexPath: IndexPath) -> (any NSView & NSCollectionViewElement)?Parameters
- elementKind:
The kind of the supplementary views you want returned. The layout object defines the kinds of supplementary views it supports. This parameter must not be
nil. - indexPath:
The index path whose supplementary view you want.
Return Value
The view for the specified index path or nil if no view is available.
Discussion
For efficiency, the collection view does not create supplementary views until they are needed. Typically, views are created only when they need to be displayed onscreen. If the collection view does not currently have a supplementary view for the specified index path, because that view would be positioned offscreen, this method returns nil.