React to pinned state of a CollectionView header

I'm in the process of rewriting a TableView as a modern CollectionView, using UICollectionLayoutListConfiguration and UICollectionViewCompositionalLayout.list together with a diffable data source.

One feature of our TableView is that it has section headers that are pinned when scrolling (plain table view style). They also change their background based on whether they are currently pinned or not. This is accomplished by setting UITableViewHeaderFooterView's automaticallyUpdatesBackgroundConfiguration to false and override updateConfiguration(using:).

However, I don't see a way of doing the same for a CollectionView's header. I can easily provide a header view by setting the supplementaryViewProvider of the data source, and they are sticky thanks to UICollectionLayoutListConfiguration.Appearance.plain But the header view itself is a UICollectionReusableView which does not seem to have the same mechanism as UITableViewHeaderFooterView for reacting to changes to the pinned state.

Is it at all possible to accomplish this with CollectionView headers? If so, how?

Answered by HolgerDe in 798929022

Ok, found the answer: the header view class can also be a UICollectionViewListCell, which provides the exact same mechanism as UITableViewHeaderFooterView.

Accepted Answer

Ok, found the answer: the header view class can also be a UICollectionViewListCell, which provides the exact same mechanism as UITableViewHeaderFooterView.

React to pinned state of a CollectionView header
 
 
Q