我的 中有几个部分UICollectionViewController
,只有第一个应该有标题。如何在从前一个第一部分删除标题的同时很好地在前面插入一个部分?
我已经设置referenceSizeForHeaderInSection
为非.zero
第一部分。这是我到目前为止所拥有的。它可以工作,但在插入动画完成后,标题明显被删除。我试图把它们放在一起,但它只是没有用
self.collectionView?.performBatchUpdates({
self.collectionView?.insertSections([0])
self.collectionView?.insertItems(at: someIndexPaths)
}, completion: { (_) in
let context = UICollectionViewFlowLayoutInvalidationContext()
context.invalidateSupplementaryElements(ofKind: UICollectionElementKindSectionHeader, at: [IndexPath(item: 0, section: 1)])
self.collectionView?.collectionViewLayout.invalidateLayout(with: context)
})