What is the use of the contentOffset property in UIScrollView ?
+3
A:
According to the documentation, the contentOffset
property represents:
The point at which the origin of the content view is offset from the origin of the scroll view.
In plain speak, it's how far the view has moved in each direction (vertical and horizontal). You can unpack vertical and horizontal distance by accessing the x
and y
properties of the CGPoint
:
CGFloat xOffset = _myScrollView.contentOffset.x;
CGFloat yOffset = _myScrollView.contentOffset.y;
Justin
2010-07-27 00:00:08
For example, if you wanted to present several (n) pages that could be scrolled through, you could create a UIScrollView with contentSize (n*pageWidth, pageHeight) and with frame size (pageWidth, pageHeight). You could then use contentOffset.x to determine (or set) which page was being (or should be) displayed.
westsider
2010-07-27 00:12:47