How can I set the scrolling position of an UIScrollView?

前端 未结 2 465
闹比i
闹比i 2021-01-07 17:50

I\'ve seen the setContentOffset:animated: method. Is that going to scroll to a specific position, or what does that \"offset\" mean?

相关标签:
2条回答
  • 2021-01-07 18:07

    Yes. From the Apple documentation:

    setContentOffset:animated: Sets the offset from the content view’s origin that corresponds to the receiver’s origin.

    0 讨论(0)
  • 2021-01-07 18:09

    You can control the animation using

    [UIView animateWithDuration:1.2 animations:^{_scrollView.contentOffset = CGPointMake(X, Y);}];
    
    0 讨论(0)
提交回复
热议问题