#pragma mark - ScrollViewDelegate
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
CGPoint point = [self nearestContentOffsetForOffset:*targetContentOffset];
targetContentOffset->x = point.x;
targetContentOffset->y = point.y;
}
- (CGPoint)nearestContentOffsetForOffset:(CGPoint)offset
{
//每次滚动的距离
CGFloat pageSize = CellWidth/CellNumber;
//四舍五入
NSInteger page = round(offset.y / pageSize);
CGFloat targetY = pageSize * page;
return CGPointMake(offset.x,targetY);
}
tableView 每次滚动定值距离
最新推荐文章于 2021-01-14 21:10:37 发布