What does contentOffset do in a UIScrollView?

后端 未结 3 748
自闭症患者
自闭症患者 2020-12-07 18:26

What is the use of the contentOffset property in UIScrollView?

3条回答
  •  误落风尘
    2020-12-07 19:16

    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;
    

提交回复
热议问题