Vous pouvez essayer quelque chose comme mettre le UILabel
sur une image:
func mapView(_ mapView: MKMapView,
viewFor annotation: MKAnnotation) -> MKAnnotationView? {
// Leave default annotation for user location
if annotation is MKUserLocation {
return nil
}
let reuseID = "Location"
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: reuseID)
if annotationView == nil {
let pin = MKAnnotationView(annotation: annotation,
reuseIdentifier: reuseID)
pin.image = UIImage(named: "cabifyPin")
pin.isEnabled = true
pin.canShowCallout = true
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
label.textColor = .white
label.text = annotation.id // set text here
pin.addSubview(label)
annotationView = pin
} else {
annotationView?.annotation = annotation
}
return annotationView
}
Voulez-vous dire 'MKAnnotationView's? Lien vers la documentation: https://developer.apple.com/reference/mapkit/mkannotationview ou recherchez sur Internet un tutoriel. –
Vous ne pouvez pas le faire sur Apple Maps, mais vous pouvez certainement le faire sur une carte dans votre propre application. – matt