I want to have a MKAnnotationView to my pins on map (using MapKit) with next attributes:
1) image
2) details button
3) another details button
4) another details button?
I have done actually adding image and details button with next code:
annotationView.detailCalloutAccessoryView = snapshotView // snapshot view is a custom view
// with image and its constraints
let detailsButton = UIButton(type: .detailDisclosure)
annotationView.rightCalloutAccessoryView = detailsButton
So, the question is how to add more than one button to MKAnnotationView
?
Because all the tutorials that I've ever seen only is "how to add details button".
You can use
detailCalloutAccessoryView
of theMKAnnotationView
to achieve that.Example how to do extension of the
MKAnnotationView
withUIStackView
:And how to implement this:
Result:![enter image description here](https://i.stack.imgur.com/mznCu.png)
I have done it
From documentation left and right calloutAccessoryView are low width and height. So, we can add buttons and image only in detailCalloutAccessoryView.
Here is my code. It's working. I haven't done a review. Because it's more clear for understanding.
CustomPin:
Works like a charm