#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 每次滚动定值距离
最新推荐文章于 2019-12-03 16:22:14 发布