layoutAttributesForDropTarget(at:)
Returns layout attributes for the drop target at the specified point.
Declaration
func layoutAttributesForDropTarget(at pointInCollectionView: NSPoint) -> NSCollectionViewLayoutAttributes?Parameters
- pointInCollectionView:
A point in the collection view’s coordinate system. Use this point to determine whether the drop would occur on an item or between items.
Return Value
A layout attributes object that identifies the element in which the drop would occur.
Discussion
The default implementation of this method tests the specified point to see if it lands inside an item, supplementary view, or decoration view of the collection view. If it does, the method returns the layout attributes for that element.
Layouts that support inter-item gaps as drop targets must override this method and use it to return the layout attributes that represent that gap. In your implementation, calculate the index path just after the gap and pass that value to the init(forInterItemGapBefore:) class method of NSCollectionViewLayoutAttributes. Set the frame property of the resulting attributes object to the rectangle that best represents the gap and also contains the specified point. When overriding this method, you can call super at any time to get the default behavior.
See Also
Providing Layout Information
layoutAttributesClassprepare()collectionViewContentSizelayoutAttributesForElements(in:)layoutAttributesForItem(at:)layoutAttributesForSupplementaryView(ofKind:at:)layoutAttributesForDecorationView(ofKind:at:)layoutAttributesForInterItemGap(before:)targetContentOffset(forProposedContentOffset:)targetContentOffset(forProposedContentOffset:withScrollingVelocity:)