Last active
June 9, 2018 10:01
-
-
Save dhl613/79cb5abf70d120c87776423764534267 to your computer and use it in GitHub Desktop.
UIScrollView下拉刷新跳动
This file contains hidden or 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
- (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