Skip to content

Instantly share code, notes, and snippets.

@dhl613
Last active June 9, 2018 10:01
Show Gist options
  • Save dhl613/79cb5abf70d120c87776423764534267 to your computer and use it in GitHub Desktop.
Save dhl613/79cb5abf70d120c87776423764534267 to your computer and use it in GitHub Desktop.
UIScrollView下拉刷新跳动
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {
CGFloat y = scrollView.contentOffset.y;
if (y < -65) {
[self.collectionView.mj_header beginRefreshing];
// 消除刷新时functionView跳动的问题 动画时间不低于0.25s
UIEdgeInsets inset = scrollView.contentInset;
dispatch_async(dispatch_get_main_queue(), ^{
[UIView animateWithDuration:0.25 animations:^{
self.scrollView.contentInset = inset;
[self.scrollView setContentOffset:CGPointMake(0, -inset.top) animated:NO];
} completion:^(BOOL finished) {
}];
});
} else if (y>0 && y<=kFunctionViewHeight) {
[self setScrollViewAnimation:y];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment