По какой-то причине в новом композиционном макете коллекции view свойство zIndex для заголовка раздела не работает. Я попробовал приведенный ниже код для достижения поведения.
func configureCategorySectionLayout() -> NSCollectionLayoutSection {
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1))
let layoutItem = NSCollectionLayoutItem(layoutSize: itemSize)
let groupSize = NSCollectionLayoutSize(widthDimension: .absolute(80), heightDimension: .absolute(105))
let groupItem = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [layoutItem])
let sectionLayout = NSCollectionLayoutSection(group: groupItem)
let sectionItem = createAddressSectionHeader()
sectionItem.zIndex = 2
sectionItem.pinToVisibleBounds = true
sectionLayout.boundarySupplementaryItems = [sectionItem]
sectionLayout.contentInsets = .init(top: 0, leading: 10, bottom: 0, trailing: 10)
sectionLayout.orthogonalScrollingBehavior = .continuous
return sectionLayout
}
func createAddressSectionHeader() -> NSCollectionLayoutBoundarySupplementaryItem {
let sectionHeaderSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .absolute(65))
let sectionHeaderItem = NSCollectionLayoutBoundarySupplementaryItem(layoutSize: sectionHeaderSize, elementKind: UICollectionView.elementKindSectionHeader, alignment: .top)
return sectionHeaderItem
}