---
title: "collectionView(_:draggingImageForItemsAt:with:offset:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscollectionviewdelegate/collectionview(_:draggingimageforitemsat:with:offset:)-4yvk5"
---

# collectionView(_:draggingImageForItemsAt:with:offset:)

Creates and returns a drag image to represent the specified items during a drag.

## Declaration

```swift
@MainActor optional func collectionView(_ collectionView: NSCollectionView, draggingImageForItemsAt indexes: IndexSet, with event: NSEvent, offset dragImageOffset: NSPointPointer) -> NSImage
```

## Parameters

- `collectionView`: The collection view making the request.
- `indexes`: The indexes of the items being dragged.
- `event`: The mouse-down event that initiated the drag.
- `dragImageOffset`: An in/out parameter that is initially set to doc://com.apple.documentation/documentation/Foundation/NSZeroPoint, which causes the image to be centered under the mouse. The value can be modified to reposition the returned image.

## Return Value

Return Value The image to use for the dragged items.

## Discussion

Discussion If the delegate does not implement this method, the collection view uses the image returned by draggingImageForItems(at:with:offset:). You do not need to implement this method for your collection view to be a drag source.

## See Also

### Legacy Collection View Support

- [collectionView(_:canDragItemsAt:with:)](appkit/nscollectionviewdelegate/collectionview(_:candragitemsat:with:)-39rjh.md)
- [collectionView(_:pasteboardWriterForItemAt:)](appkit/nscollectionviewdelegate/collectionview(_:pasteboardwriterforitemat:)-7ldvs.md)
- [collectionView(_:writeItemsAt:to:)](appkit/nscollectionviewdelegate/collectionview(_:writeitemsat:to:)-a1lk.md)
- [collectionView(_:namesOfPromisedFilesDroppedAtDestination:forDraggedItemsAt:)](appkit/nscollectionviewdelegate/collectionview(_:namesofpromisedfilesdroppedatdestination:fordraggeditemsat:)-wwec.md)
- [collectionView(_:draggingSession:willBeginAt:forItemsAt:)](appkit/nscollectionviewdelegate/collectionview(_:draggingsession:willbeginat:foritemsat:)-cpuq.md)
- [collectionView(_:validateDrop:proposedIndex:dropOperation:)](appkit/nscollectionviewdelegate/collectionview(_:validatedrop:proposedindex:dropoperation:).md)
- [collectionView(_:acceptDrop:index:dropOperation:)](appkit/nscollectionviewdelegate/collectionview(_:acceptdrop:index:dropoperation:).md)
