Gist time: https://gist.github.com/mnmaraes/9529586
The magic happens at:
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat xDelta = scrollView.contentOffset.x;
self.topView.center = CGPointMake(self.topCenterInitialX + xDelta, self.topView.center.y);
}
So to explain better. You have a bottomView
and a topView
which are exactly the same, except the colors are switched. The topView
is contained in a clipperView
which is inside a UIScrollView
(To handle panning and swiping). So when you scroll right/left the topView
moves the opposite direction giving the impression that it is stationary, the excess is then clipped by clipperView
. Anyways, it's all there. Let me know if you don't understand something.
Have fun!