iPhone UIScrollView Speed Check

后端 未结 8 1639
梦如初夏
梦如初夏 2020-11-30 19:31

I know how to get the contentOffset on movement for a UIScrollView, can someone explain to me how I can get an actual number that represents the current speed of a UIScrollV

8条回答
  •  我在风中等你
    2020-11-30 20:17

    You can see PageControl sample code about how to get the contentOffset of scrollview.

    The contentOffset on movement can be obtained from UIScrollViewDelegate method, named - (void)scrollViewDidScroll:(UIScrollView *)scrollView, by querying scrollView.contentOffset. Current speed can be calculated by delta_offset and delta_time.

    • Delta_offset = current_offset - pre_offset;
    • Delta_time = current_time - pre_time;

提交回复
热议问题