Thursday, 28 June 2018

Get frame of Drag preview

I'm implementing drag-n-drop on UICollectionView using a new Apple's API introduced in iOS 11.
What I need is to get a frame of drag preview (see below, red rectangle) iOS Drag and drop on UICollectionView
I tried to get drag's location:
extension ViewController: UICollectionViewDropDelegate {
    func collectionView(_ collectionView: UICollectionView, 
         dropSessionDidUpdate session: UIDropSession, 
         withDestinationIndexPath destinationIndexPath: IndexPath?) -> UICollectionViewDropProposal {
        let location = session.location(in: collectionView)
    }

but it represents my finger's location only. I need to get the entire frame or, at least, it's origin.
I also tried to store y position of touch in my cell and then do something like dragLocation.y - touchLocationInCell.y, but this approach is not accurate: looks like the preview gets some offset from the touch location.


from Get frame of Drag preview

No comments:

Post a Comment