Segmented button + scrollable content UI pattern

I’m trying to recreate a UI pattern I’ve seen on native apps that looks like this:

  • Title (fixed in place)
  • Segmented button, two options (fixed in place)
  • Scrollable content. Content depends on what is selected in the segmented button. When you toggle your option in the segmented button, there’s a nice sideways animation where one section leaves the view and the other comes on.

I haven’t been able to get this to work yet, having the segmented button stay in place and not scroll. And I haven’t figured out the best strategy for the animation - should I have two content sections with one hidden off screen?

Just wondering if someone knows of the best practice here.