Created
December 5, 2019 11:32
-
-
Save qy1010/bf9521414e7564b4c404c908d09d7d2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@property (nonatomic, assign) NSInteger lastcontentOffset; //添加此属性的作用,根据差值,判断ScrollView是上滑还是下拉 | |
//<UIScrollViewDelegate > | |
- (void)scrollViewDidScroll:(UIScrollView *)scrollView | |
{ | |
CGFloat hight = scrollView.frame.size.height; | |
CGFloat contentOffset = scrollView.contentOffset.y; | |
CGFloat distanceFromBottom = scrollView.contentSize.height - contentOffset; | |
CGFloat offset = contentOffset - self.lastcontentOffset; | |
self.lastcontentOffset = contentOffset; | |
if (offset > 0 && contentOffset > 0) { | |
NSLog(@"上拉行为"); | |
} | |
if (offset < 0 && distanceFromBottom > hight) { | |
NSLog(@"下拉行为"); | |
} | |
if (contentOffset == 0) { | |
NSLog(@"滑动到顶部"); | |
} | |
if (distanceFromBottom < hight) { | |
NSLog(@"滑动到底部"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment