Gavin Beard
Gavin Beard

Reputation: 199

Mapkit annotation anchor point

I'm using a custom image for MapKit annotations using :

func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {}

The "pin" shows with the right image now when I add a new annotation to my map, but it seems to use the horizontal and vertical centre of the image as the pin point. Is it possible to make this the bottom centre of the image? I could create a new image thats double the hight with the bottom being blank, but was hoping I could do this programmatically Thanks

Upvotes: 3

Views: 1701

Answers (1)

Mando
Mando

Reputation: 11712

  • anchorPoint for iOS 16+ only - relative values from 0 to 1
  • centerOffset for earlier iOS versions - absolutely values, depends on image size

Upvotes: 0

Related Questions