UIScollerView的代理方法有很多,用的比较多的可能是 - (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
}
有很多时候我们需要跟进手指最后释放的位置来判断试图应该用下来这个代理方法
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
if (scrollView.contentOffset.x >= 40) {
[UIView animateWithDuration:0.5 animations:^{
scrollView.contentOffset = CGPointMake(80, 0);
}];
} else {
[UIView animateWithDuration:0.5 animations:^{
scrollView.contentOffset = CGPointZero;
}];
}
}