Skip to content
Browse files

Fixed incorrect cells alignment when using a contentInset != zero

  • Loading branch information...
1 parent 4ee30d4 commit 04f4d31104bedce61919720007d44fe0ee5ea4fa @ldesroziers committed Jul 30, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 NRGridView/NRGridView/NRGridView.m
View
4 NRGridView/NRGridView/NRGridView.m
@@ -959,7 +959,7 @@ - (CGRect)__rectForCellAtIndexPath:(NSIndexPath*)indexPath
NSInteger currentColumn = (NSInteger)(indexPath.itemIndex - numberOfCellsPerLine*currentLine);
cellFrame.origin.y = CGRectGetMinY([sectionLayout contentFrame]) + floor([self cellSize].height * currentLine);
- cellFrame.origin.x = floor([self cellSize].width * currentColumn) + floor(CGRectGetWidth([self bounds])/2. - lineWidth/2.);
+ cellFrame.origin.x = floor([self cellSize].width * currentColumn) + floor((CGRectGetWidth([self bounds]) - ([self contentInset].left + [self contentInset].right))/2. - lineWidth/2.);
}
}else if(layoutStyle == NRGridViewLayoutStyleHorizontal)
@@ -976,7 +976,7 @@ - (CGRect)__rectForCellAtIndexPath:(NSIndexPath*)indexPath
NSInteger currentLine = (NSInteger)(indexPath.itemIndex - numberOfCellsPerColumn*currentColumn);
cellFrame.origin.x = CGRectGetMinX([sectionLayout contentFrame]) + floor([self cellSize].width * currentColumn);
- cellFrame.origin.y = floor([self cellSize].height * currentLine) + floor(CGRectGetHeight([self bounds])/2. - columnHeight/2.);
+ cellFrame.origin.y = floor([self cellSize].height * currentLine) + floor((CGRectGetHeight([self bounds]) - ([self contentInset].top + [self contentInset].bottom))/2. - columnHeight/2.);
}
}

0 comments on commit 04f4d31

Please sign in to comment.
Something went wrong with that request. Please try again.