默认的collectionview deleteItems将淡出单元格,我想更改此动画以使单元格像Tinder应用程序一样飞出屏幕。请帮忙

self.collectionView.performBatchUpdates({
     self.likedArrayData?.append(self.arrayData![indexPath.item])
     self.arrayData?.remove(at: indexPath.item)
     self.collectionView.deleteItems(at:[indexPath])
}, completion: { [unowned self] (_) in

})


ios - 如何自定义动画以删除集合 View 单元格?-LMLPHP

最佳答案

let cell = self.collectionView!.cellForItem(at: indexPath)
                UIView.animate(withDuration: 0.5, animations: {
                    cell?.center.y -= 500 // Move up 500 pixels
                    cell?.alpha = 0.0 //the cell will come back from top so I set al[ha to 0.0
                }, completion: { (_) in
                    self.collectionView.performBatchUpdates({
                        self.likedArrayData?.append(self.arrayData![indexPath.item])
                        self.arrayData?.remove(at: indexPath.item)
                        self.collectionView.deleteItems(at:[indexPath])
                    }, completion: { [unowned self] (_) in

                    })
                })

10-07 19:49
查看更多