2017-12-20 5 views
1

Ich versuche, die Standardfarbe der Cluster-Annotation Mapkit für iOS, swift.Ändern Sie die Farbe der Cluster-Annotation im Markt. iOS, Swift

Ist es möglich. Ich kann die einzelnen Anmerkungen ändern, aber nicht den Cluster.

Unten ist mein Code.

@available(iOS 11.0, *) 
    func mapView(_ mapView: MKMapView, clusterAnnotationForMemberAnnotations memberAnnotations: [MKAnnotation]) -> MKClusterAnnotation { 
     let vehicles = MKClusterAnnotation(memberAnnotations: memberAnnotations) 
     vehicles.title = "Photos" 
     vehicles.subtitle = nil 
     return vehicles 
    } 

Antwort

3

Verwendung markerTintColor.

https://developer.apple.com/documentation/mapkit/mkmarkerannotationview/2873822-markertintcolor

z.B.

func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { 
    let identifier = "marker" 
    var view: MKMarkerAnnotationView 

    if let dequeuedView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier) 
     as? MKMarkerAnnotationView { 
     dequeuedView.annotation = annotation 
     view = dequeuedView 
    } else { 
     view = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: identifier) 
     view.markerTintColor = .blue 
    } 
    return view 
} 
Verwandte Themen