Instance Method


Registers a nib file for use in creating supplementary views for the collection view.


func register(_ nib: UINib?, forSupplementaryViewOfKind kind: String, withReuseIdentifier identifier: String)



The nib object containing the view object. The nib file must contain only one top-level object and that object must be of the type UICollectionReusableView.


The kind of supplementary view to create. The layout defines the types of supplementary views it supports. The value of this string may correspond to one of the predefined kind strings or to a custom string that the layout added to support a new type of supplementary view. This parameter must not be nil.


The reuse identifier to associate with the specified nib file. This parameter must not be nil and must not be an empty string.


Prior to calling the dequeueReusableSupplementaryView(ofKind:withReuseIdentifier:for:) method of the collection view, you must use this method or the register(_:forSupplementaryViewOfKind:withReuseIdentifier:) method to tell the collection view how to create a supplementary view of the given type. If a view of the specified type is not currently in a reuse queue, the collection view uses the provided information to create a view object automatically.

If you previously registered a class or nib file with the same element kind and reuse identifier, the class you specify in the viewClass parameter replaces the old entry. You may specify nil for nib if you want to unregister the class from the specified element kind and reuse identifier.

See Also

Creating Collection View Cells

func register(AnyClass?, forCellWithReuseIdentifier: String)

Register a class for use in creating new collection view cells.

func register(UINib?, forCellWithReuseIdentifier: String)

Register a nib file for use in creating new collection view cells.

func register(AnyClass?, forSupplementaryViewOfKind: String, withReuseIdentifier: String)

Registers a class for use in creating supplementary views for the collection view.