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

# setSelected(_:animated:)

Sets the selection state of the annotation view.

```
func setSelected(_ selected: Bool, animated: Bool)
```

## Parameters

`selected`

Contains the value <doc://com.apple.documentation/documentation/Swift/true> if the view displays in a selected state.

`animated`

Set to <doc://com.apple.documentation/documentation/Swift/true> if the map view animates the change in selection state.

## Discussion

Dont call this method directly. An [`MKMapView`](/documentation/MapKit/MKMapView) object calls this method in response to user interactions with the annotation.

## See Also

[`selectAnnotation(_:animated:)`](/documentation/MapKit/MKMapView/selectAnnotation(_:animated:))

Selects the specified annotation and displays a callout view for it.



---

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)