<!--
{
  "availability" : [
    "iOS: 4.2.0 -",
    "iPadOS: 4.2.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MapKit",
  "identifier" : "/documentation/MapKit/MKAnnotationView/setDragState(_:animated:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "MapKit"
    ],
    "preciseIdentifier" : "c:objc(cs)MKAnnotationView(im)setDragState:animated:"
  },
  "title" : "setDragState(_:animated:)"
}
-->

# setDragState(_:animated:)

Sets the drag state for the annotation view.

```
func setDragState(_ newDragState: MKAnnotationView.DragState, animated: Bool)
```

## Parameters

`newDragState`

The new drag state for the annotation view.

`animated`

If <doc://com.apple.documentation/documentation/Swift/true>, the map view animates the change to the new drag state; otherwise, the map view makes the change without animations.

## Discussion

Apps can override this method and use it to implement drag support for custom annotation views. As the system detects user actions that indicate a drag, it calls this method to update the drag state. In response to these changes, your custom implementation of this method needs to do the following:

- When the drag state changes to [`MKAnnotationView.DragState.starting`](/documentation/MapKit/MKAnnotationView/DragState-swift.enum/starting), set the state to [`MKAnnotationView.DragState.dragging`](/documentation/MapKit/MKAnnotationView/DragState-swift.enum/dragging). If you perform an animation to indicate the beginning of a drag, and the `animated` parameter is <doc://com.apple.documentation/documentation/Swift/true>, perform that animation before changing the state.
- When the state changes to either [`MKAnnotationView.DragState.canceling`](/documentation/MapKit/MKAnnotationView/DragState-swift.enum/canceling) or [`MKAnnotationView.DragState.ending`](/documentation/MapKit/MKAnnotationView/DragState-swift.enum/ending), set the state to [`MKAnnotationView.DragState.none`](/documentation/MapKit/MKAnnotationView/DragState-swift.enum/none). If you perform an animation at the end of a drag, and the `animated` parameter is <doc://com.apple.documentation/documentation/Swift/true>, perform that animation before changing the state.

The default implementation of this method sets the value of the [`dragState`](/documentation/MapKit/MKAnnotationView/dragState-swift.property) property to the value in the `newDragState` parameter only. Therefore, direct subclasses can call the inherited version of this method to change the drag state; otherwise, change the value in the [`isDraggable`](/documentation/MapKit/MKAnnotationView/isDraggable) property directly.

Changing the state to [`MKAnnotationView.DragState.dragging`](/documentation/MapKit/MKAnnotationView/DragState-swift.enum/dragging) or [`MKAnnotationView.DragState.none`](/documentation/MapKit/MKAnnotationView/DragState-swift.enum/none) is the way to signal to the map view when you finish performing animations. For example, when a drag operation begins for an annotation, the class executes an animation to lift the view off the map. Similarly, when the user drops the annotation, the class performs a drop animation. Even if you don’t perform any animations, call the inherited version of this method to update the [`dragState`](/documentation/MapKit/MKAnnotationView/dragState-swift.property) property.

Don’t try to stop a new drag operation by changing the state from [`MKAnnotationView.DragState.starting`](/documentation/MapKit/MKAnnotationView/DragState-swift.enum/starting) to [`MKAnnotationView.DragState.none`](/documentation/MapKit/MKAnnotationView/DragState-swift.enum/none). If you don’t want your annotation view to be draggable, set the [`isDraggable`](/documentation/MapKit/MKAnnotationView/isDraggable) property to <doc://com.apple.documentation/documentation/Swift/false>.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)