File tree 1 file changed +8
-6
lines changed
UICollectionViewLeftAlignedLayout
1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -44,18 +44,20 @@ @implementation UICollectionViewLeftAlignedLayout
44
44
#pragma mark - UICollectionViewLayout
45
45
46
46
- (NSArray *)layoutAttributesForElementsInRect : (CGRect )rect {
47
- NSArray * attributesToReturn = [super layoutAttributesForElementsInRect: rect];
48
- for (UICollectionViewLayoutAttributes* attributes in attributesToReturn) {
49
- if (nil == attributes.representedElementKind ) {
50
- NSIndexPath * indexPath = attributes.indexPath ;
51
- attributes.frame = [self layoutAttributesForItemAtIndexPath: indexPath].frame ;
47
+ NSMutableArray * attributesToReturn = [NSMutableArray array ];
48
+ for (UICollectionViewLayoutAttributes* attributes in [super layoutAttributesForElementsInRect: rect]) {
49
+ UICollectionViewLayoutAttributes* attributesCopy = [attributes copy ];
50
+ if (nil == attributesCopy.representedElementKind ) {
51
+ NSIndexPath * indexPath = attributesCopy.indexPath ;
52
+ attributesCopy.frame = [self layoutAttributesForItemAtIndexPath: indexPath].frame ;
52
53
}
54
+ [attributesToReturn addObject: attributesCopy];
53
55
}
54
56
return attributesToReturn;
55
57
}
56
58
57
59
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath : (NSIndexPath *)indexPath {
58
- UICollectionViewLayoutAttributes* currentItemAttributes = [super layoutAttributesForItemAtIndexPath: indexPath];
60
+ UICollectionViewLayoutAttributes* currentItemAttributes = [[ super layoutAttributesForItemAtIndexPath: indexPath] copy ];
59
61
UIEdgeInsets sectionInset = [self evaluatedSectionInsetForItemAtIndex: indexPath.section];
60
62
61
63
BOOL isFirstItemInSection = indexPath.item == 0 ;
You can’t perform that action at this time.
0 commit comments