I'm looking for the best way to make the following animation. I've tried some solutions, but none of them seem to tackle my problem as every single solution seems to fail at some point. The animation I need to do is the following:
User swipes his finger up and the tableView & 1 & 2 scroll up (it's like tableView & 1 & 2 are one scrollable element). Then, when 2 becomes invisible upon the scroll, 3 & 1 & tableView become scrollable (again, as if it were one scrollable element). Then, when 3 becomes invisible (as it is scrolled) the tableView is then the only scrollable element.
What I tried:
I initially tried with simple animations like changing height constraints for every 1/2/3 element based on the scroll offset and although it seemed fine to me, it didn't to the reviewer as he wanted more precise scrolling in between hiding elements animations
I then tried to combine panGesture with scroll. I embedded 1 & 2 and tableView into one scroll View and set panGesture recognizer for it with delegate function shouldRecognizeSimultaneouslyWith returning true while having tableView scrolling disabled. Then, upon intersecting 3 I was disabling the panGesture and tried to enable tableView scrolling, but failed to recognize which panGesture/scrolling works or not, which one to disable, which one to fail or work alone/simultaneously.
How would you dear developers tackle it so that the animations are smooth and as described? Perhaps, you have an awesome idea :)


I think you'll be fighting a losing battle trying to toggle scrolling.
Here's another approach...
UIViewcontentInset.topof the height of the three views plus vertical spacing3will stick to the top, until it is pushed up by12till slide under3when1pushes it up1when the tableView scrollsYou can try it with this example code (no
@IBOutletconnections needed):Here's how it looks to start:
then, after scrolling up just a bit (
2is sliding under3):scrolling a bit more (
1is pushing3up and out of view):and then table scrolling while
1remains at the top: