CAScrollLayer is surprisingly simple, which can be confusing.
Just add a content layer to it:
[_scrollLayer addSublayer:_contentLayer]
To set the rectangle, you want to be visible on the screen, set the borders or frame of the scroll layer:
[_scrollLayer setBounds:visibleBounds]
Set the content size accordingly. The size of the content can be larger or smaller, it does not matter.
[_contentLayer setBounds:currentContextBounds]
If the content is larger and you want to scroll to a specific point, use the scrollToPoint: or scrollToRect: methods of the scroll layer.
If necessary, you need to implement your own scroll indicators, columns, etc.
source share