collectionView(_:layout:referenceSizeForHeaderInSection:)
Asks the delegate for the size of the header view in the specified section.
Declaration
optional func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSizeParameters
- collectionView:
The collection view object displaying the flow layout.
- collectionViewLayout:
The layout object requesting the information.
- section:
The index of the section whose header size is being requested.
Return Value
The size of the header. If you return a value of size (0, 0), no header is added.
Discussion
If you do not implement this method, the flow layout uses the value in its headerReferenceSize property to set the size of the header.
During layout, only the size that corresponds to the appropriate scrolling direction is used. For example, for the vertical scrolling direction, the layout object uses the height value returned by your method. (In that instance, the width of the header would be set to the width of the collection view.) If the size in the appropriate scrolling dimension is 0, no header is added.