From 59bbe7daaf997bd191e6489fa9d2182b0cb40399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CB=90=CC=97=CC=80=28=EA=99=A8=EA=99=A8=29=CB=90=CC=96?= =?UTF-8?q?=CC=81=E8=BF=B7=E3=81=AE=E8=BD=AF=E7=B3=AF?= <553296416@qq.com> Date: Sat, 18 Mar 2017 03:48:14 +0800 Subject: [PATCH] commit "Get wrong cell displacement when cell's width equal to device width" --- .../UICollectionViewLeftAlignedLayout.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/UICollectionViewLeftAlignedLayout/UICollectionViewLeftAlignedLayout.m b/UICollectionViewLeftAlignedLayout/UICollectionViewLeftAlignedLayout.m index 5a859ec..4228400 100644 --- a/UICollectionViewLeftAlignedLayout/UICollectionViewLeftAlignedLayout.m +++ b/UICollectionViewLeftAlignedLayout/UICollectionViewLeftAlignedLayout.m @@ -87,7 +87,16 @@ - (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSInde } CGRect frame = currentItemAttributes.frame; - frame.origin.x = previousFrameRightPoint + [self evaluatedMinimumInteritemSpacingForSectionAtIndex:indexPath.section]; + + CGFloat originX=previousFrameRightPoint + [self evaluatedMinimumInteritemSpacingForSectionAtIndex:indexPath.section]; + if (originX>=[UIScreen mainScreen].bounds.size.width) { + frame.origin.x=[self evaluatedMinimumInteritemSpacingForSectionAtIndex:indexPath.section]; + } + else + { + frame.origin.x =originX; + } + currentItemAttributes.frame = frame; return currentItemAttributes; }