I'm trying to recreate a UI from instagram, something like this. I thought that they were using collectionViews embedded into another UICollectionView or a UIPagingViewController.

I tried to recreate it, but I have a problem with moving the header up when the collectionView, it doesn't matter which one, scrolls up.

Here's my result so far

What should I do? Obviously I am not talking about the all the subviews that instagram has in its header, I am only talking about the header itself that should scroll up (and the segmentedControl should not scroll outside the safe area)

Thank you for your precious help.