Is it possible to swap 2 cells in a UICollectionView that is using UICollectionViewFlowLayout?

后端 未结 3 1763
我寻月下人不归
我寻月下人不归 2021-02-05 15:54

Say I have a UICollectionView using a UICollectionViewFlowLayout and the following format:

1 2 3
4 5 6
7 8 9

I touch cell 9 and drag it over ce

3条回答
  •  失恋的感觉
    2021-02-05 16:03

    Swift code:

            self.collectionView.performBatchUpdates({
                self.collectionView.moveItem(at: selectedIndexPath, to: targetIndexPath)
                self.collectionView.moveItem(at: targetIndexPath, to: selectedIndexPath)
            }, completion: nil)
    

提交回复
热议问题