Skip to content

Commit 3520e65

Browse files
Merge pull request #109 from kishikawakatsumi/background-decoration-zindex
Promoted section items' zIndex to 1 if section has decoration items.
2 parents 52f6f94 + 2959234 commit 3520e65

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

Sources/IBPCollectionViewCompositionalLayout/IBPNSCollectionLayoutSection.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ - (BOOL)scrollsOrthogonally {
3838
return self.orthogonalScrollingBehavior != IBPUICollectionLayoutSectionOrthogonalScrollingBehaviorNone;
3939
}
4040

41+
- (BOOL)hasBackgroundDecorationItem {
42+
return self.decorationItems.count > 0;
43+
}
44+
4145
@end

Sources/IBPCollectionViewCompositionalLayout/IBPNSCollectionLayoutSection_Private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ NS_ASSUME_NONNULL_BEGIN
77

88
@property (nonatomic, copy) IBPNSCollectionLayoutGroup *group;
99
@property (nonatomic, readonly) BOOL scrollsOrthogonally;
10+
@property (nonatomic, readonly) BOOL hasBackgroundDecorationItem;
1011

1112
@end
1213

Sources/IBPCollectionViewCompositionalLayout/IBPUICollectionViewCompositionalLayout.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ - (void)prepareLayout {
200200
}
201201

202202
cellAttributes.frame = cellFrame;
203+
cellAttributes.zIndex = layoutSection.hasBackgroundDecorationItem ? 1 : 0;
203204

204205
if (!layoutSection.scrollsOrthogonally) {
205206
cachedItemAttributes[indexPath] = cellAttributes;

Sources/IBPCollectionViewCompositionalLayout/include/IBPNSCollectionLayoutDecorationItem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
3636
- (instancetype)init NS_UNAVAILABLE;
3737
+ (instancetype)new NS_UNAVAILABLE;
3838

39-
@property (nonatomic) NSInteger zIndex;
39+
@property (nonatomic) NSInteger zIndex; // default is 0; all other section items will be automatically be promoted to zIndex=1
4040
@property (nonatomic, readonly) NSString *elementKind;
4141
@property (nonatomic) IBPNSDirectionalEdgeInsets contentInsets;
4242

0 commit comments

Comments
 (0)