推荐答案 NSCollectionLayoutSupplementaryItem子类是NSCollectionLayoutItem的子类,因此您应该可以将其添加为组的子项.所以你会用NSCollectionLayoutSupplementaryItem subclasses NSCollectionLayoutItem, so you should be able to add it as a subitem of your group. So you'd uselet item = NSCollectionLayoutItem( layoutSize: .init(widthDimension: .fractionalWidth(1.0), heightDimension: .fractional(1)) )let sup = NSCollectionLayoutSupplementaryItem( layoutSize: .init(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(2)), elementKind: "LineReusableView", containerAnchor: .init(edges: [.bottom]) )let threeItemGroup = NSCollectionLayoutGroup.horizontal(layoutSize: groupLayoutSize, subitem: item, count: 3)let group = NSCollectionLayoutGroup.vertical(layoutSize: layoutGroupSize,subitems: [threeItemGroup,sup])let section = NSCollectionLayoutSection(group: group)这应该导致您每个组的底部只有一行,而不是您希望的三行,但是您应该能够更改设计补充视图时的外观(使其绘制3条不同的线,而不仅仅是1).This should result in you only having one line at the bottom of each group rather than your desired three lines, but you should be able to change how that looks in designing your supplementary view (making it draw 3 distinct lines rather than just 1). 这篇关于如何使用UICollectionViewCompositionalLayout创建具有相等行高的网格布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 06-28 02:54