Collection View Sticky Header

Hello, I am currently working on collection view header.

I want to make header of the collection view always stay up at the top. So I set the sectionHeadersPinToVisibleBounds property to true, but this did not work as expected.

When I scroll down the header moves along with the cells, but if I scroll up the header does not move and stays the same.

I guess I'm using it wrong. How can I fix this?

In ViewDidLoad i put code below.

let layout = col.collectionViewLayout as! UICollectionViewFlowLayout
    layout.sectionHeadersPinToVisibleBounds = true

Thanks for reading this! Please help me

Collection View Sticky Header
 
 
Q