First, it would be better that you change your view hierarchy to
UINavigationController -> UIViewController-> UICollectionView & custom view
In your current code, have you added the collection view as a cell in the tableview?
Well, since the collection view is inherently scrollable, this is not necessary.
besides, if you add your custom view
to the tableview or the collection view, the custom view
will scroll alongside with the scrollable view, which, i bet, is not what you want.
so what you may do is to:
1. add the `custom view` to the view of the `UIViewController`
2. add also the `collection view` to the `UIViewController`
3. implement `UICollectionViewDelegate`, `UICollectionViewDataSource` for the `UIViewController`
4. implement 'scrollViewDidScroll' in 'UIScrollViewDelegate' for the `UIViewController` to detect scroll action
5. get scroll direction as indicated here:
Finding the direction of scrolling in a UIScrollView?
6. when a scroll is detected, set the desired frame of your custom view in [UIView animateWithDuration:animations:], and adjust speed by adjusting the duration of the animation.
7. Done!
well, just in case.... you can set the origin of the frame as negative to move the custom view
outside the view of the UIViewController