let items = self.dataSource.snapshot().itemIdentifiers(inSection: 2)
let group = NSCollectionLayoutGroup.custom(layoutSize: groupSize) { (env) -> [NSCollectionLayoutGroupCustomItem] in
var customItems = [NSCollectionLayoutGroupCustomItem]()
items.forEach { (object) in
switch object.imageURL {
case .none:
//calculate frame and append item
customItems.append(NSCollectionLayoutGroupCustomItem(frame: yourFrame))
case .some(_):
//calculate frame and append item
customItems.append(NSCollectionLayoutGroupCustomItem(frame: yourFrame))
}
}
return customItems
}
2条答案
按热度按时间3z6pesqy1#
我最终使用了NSCollectionLayoutGroup.custom,它允许您分别调整属于一个组的每个项目的大小。
r7s23pms2#
有人在这里吗,我建议你试试
我猜compos layout会自动计算item和item2的.estimated()的height并应用该计算。