NSCollectionLayoutSupplementaryItem在单元格下面显示

时间:2019-11-30 09:21:40

标签: ios uicollectionview

我使用WWDC中的代码添加了徽章。但是徽章显示在单元格下面。 然后,如果我滚动,它会闪烁并且有时变得可见,而其他时候则停留在后面。 这是错误吗?

 let badgeAnchor = NSCollectionLayoutAnchor(edges: [.bottom, .trailing], fractionalOffset: CGPoint(x: 0.3, y: 0.3))
            let badgeSize = NSCollectionLayoutSize(widthDimension: .absolute(30),
                                                  heightDimension: .absolute(30))
            let badge = NSCollectionLayoutSupplementaryItem(
                layoutSize: badgeSize,
                elementKind: "Tick",
                containerAnchor: badgeAnchor)

            let item = NSCollectionLayoutItem(layoutSize: itemSize,supplementaryItems: [badge])
            group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitem:item, count: sectionLayoutKind.columnCount)

1 个答案:

答案 0 :(得分:0)

经过一系列的测试,把section.orthogonalScrollingBehavior改成continuous或者其他行为,可能导致这个bug,应该向apple报告这个bug

let section = NSCollectionLayoutSection(group: group)
section.orthogonalScrollingBehavior = .continuous 

enter image description here