美文网首页
判断UIScrollView 滚动方向

判断UIScrollView 滚动方向

作者: Best_Kai | 来源:发表于2016-08-21 17:45 被阅读1025次

如何判断UIScrollView 的滚动方向? 代码如下:

  float lastContentOffset;
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
int currentPostion = scrollView.contentOffset.y;
if (currentPostion - lastContentOffset > 15) {
    lastContentOffset = currentPostion;
//        NSLog(@"ScrollUp now");
}
else if (lastContentOffset - currentPostion > 15)
{
    lastContentOffset = currentPostion;
//        NSLog(@"ScrollDown now");
}
};

/*15表示滑动多少距离才开始判断,可以自定义.....左右方向同理*/

相关文章

网友评论

      本文标题:判断UIScrollView 滚动方向

      本文链接:https://www.haomeiwen.com/subject/hpkwsttx.html