2

I'm using iOS 11 drag and drop API for reordering and want to remove translucent cell which appears on start dragging. Is it possible? For dragging I use only required method of 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];
}

enter image description here

2
  • can you get cell start dragging method?
    – AtulParmar
    Commented Jan 10, 2019 at 7:52
  • nah. if u want custom behaviour of ios object, then u need customize it
    – GeneCode
    Commented Jan 11, 2019 at 0:00

2 Answers 2

1

You can customize your cell during the drag/drop lifecycle by overriding 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

        }
    }
}
-1

On your cell class override this method:

override func dragStateDidChange(_ dragState: UICollectionViewCell.DragState) {

    switch dragState {
    case .none:

        self.layer.opacity = 1

    case .lifting:

        return

    case .dragging:

        self.layer.opacity = 0
    }
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.