我正在使用iOS 11拖放应用程序接口进行重新排序,并希望删除开始拖动时出现的半透明单元格。有可能吗?对于拖动,我只使用UICollectionViewDragDelegate的必需方法:
- (nonnull NSArray<UIDragItem *> *)collectionView:(nonnull UICollectionView *)collectionView
itemsForBeginningDragSession:(nonnull id<UIDragSession>)session
atIndexPath:(nonnull NSIndexPath *)indexPath {
NSItemProvider *itemProvider = [NSItemProvider new];
UIDragItem *dragItem = [[UIDragItem alloc] initWithItemProvider:itemProvider];
return @[dragItem];
}

发布于 2020-01-31 00:04:10
您可以在拖放生命周期中通过覆盖dragStateDidChange(_ dragState: UICollectionViewCell.DragState)来自定义单元格
class MyCell: UICollectionViewCell {
//...
override func dragStateDidChange(_ dragState: UICollectionViewCell.DragState) {
switch dragState {
case .none:
self.layer.opacity = 1
case .lifting:
return
case .dragging:
self.layer.opacity = 0
}
}
}发布于 2020-09-23 00:16:38
在你的单元格类上重写这个方法:
override func dragStateDidChange(_ dragState: UICollectionViewCell.DragState) {
switch dragState {
case .none:
self.layer.opacity = 1
case .lifting:
return
case .dragging:
self.layer.opacity = 0
}
}https://stackoverflow.com/questions/54124018
复制相似问题