【发布时间】:2017-10-13 08:56:45
【问题描述】:
【问题讨论】:
标签: mapkit ios11 mapkitannotation
【问题讨论】:
标签: mapkit ios11 mapkitannotation
没关系,我设法弄明白了。
我在代理的mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) 函数中添加了以下内容。
if let cluster = annotation as? MKClusterAnnotation {
let markerAnnotationView = MKMarkerAnnotationView()
markerAnnotationView.glyphText = String(cluster.memberAnnotations.count)
markerAnnotationView.markerTintColor = UIColor.appPrimary
markerAnnotationView.canShowCallout = false
return markerAnnotationView
}
【讨论】:
如果你不使用MKMapViewDelegate,你可以在你的MKMarkerAnnotationView子类中设置,
clusteringIdentifier = MKMapViewDefaultClusterAnnotationViewReuseIdentifier
在你的视图控制器中
mapView.register(SubclassMarkerView.self, forAnnotationViewWithReuseIdentifier: MKMapViewDefaultAnnotationViewReuseIdentifier)
mapView.register(SubclassMarkerView.self, forAnnotationViewWithReuseIdentifier: MKMapViewDefaultClusterAnnotationViewReuseIdentifier)
【讨论】: