iOS UIScrollView是否正在滚动事件处理

项目开发过程中,有时候会遇到这样的需求:列表滚动的时候隐藏页面中的某个按钮,停止的时候显示该按钮。话不多说,效果如下图:
Unknown.gif

实现思路如下:
1.利用UIScrollViewDelegate方法来实现
2.scrollView滚动代理 - (void)scrollViewDidScroll:(UIScrollView *)scrollView;
3.scrollView滑动结束代理 - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
4.scrollView滚动停止代理 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [self setPostBtnDisplayWithScrolling:scrollView.isDragging||scrollView.isDecelerating];
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    [self setPostBtnDisplayWithScrolling:scrollView.isDragging&&scrollView.isDecelerating];
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    [self setPostBtnDisplayWithScrolling:scrollView.isTracking&&scrollView.isDragging&&scrollView.isDecelerating];
}

好了,也没什么可以详细讲的了,喜欢的朋友点颗❤️呗...

你可能感兴趣的:(iOS UIScrollView是否正在滚动事件处理)