How to make UICollectionView header appear when scrolling up a bit?

92 Views Asked by At

In many apps like Instagram (search) or Whatsapp (chats) when you scroll down the header disappears, but if you scroll up a little big the header reappears again. The cool thing is that you don't have to scroll to very top to see the header.

How is this implemented? I'm sorry if I'm not expressing myself correctly.

1

There are 1 best solutions below

0
de. On

You will have to implement it by hand. Implement scrollViewDidScroll: and add the logic there.

  • store the previous contentOffset in a property
  • compare with current contentOffset, derive the scroll direction
  • when scrolling down, subtract the offset difference from you header position until it is off-screen
  • when scrolling up, do the opposite.