UICollectionView组成布局中的节标题z索引

由于新的uicollectionview组成布局中的某些原因,部分标题的z索引属性不起作用。我尝试下面的代码来实现该行为。

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
    }

enter image description here

enter image description here

评论