I want to set the header to collection view, just like UITableViewController\'s setTableHeader does.
I found the way to set the each section\'s header on collection view
I implemented this using a custom layout and repositioning the header on every scroll event. Start with subclassing UICollectionViewLayout, there are tons of tutorial on the web, this is a good one: http://markpospesel.wordpress.com/2012/10/25/fixing-circlelayout/
Then the trick is to always return YES
to shouldInvalidateLayoutForBoundsChange:
, and in prepareLayout
reposition (ie. change the layoutAttributes' frame) the header based on the collection view xOffset and yOffset.
Use a supplementary view with NSIndexPath 0-0.
layoutAttributesForElementsInRect:
will be called on every frame, so if you have a lot of items in your collection view, you will need to cache the result so it does not impact performance. All attributes should be untouched except for that one header.
Source: I spent 1 month working on this particular topic.