gpt4 book ai didi

ios - 更改市场中集群注释的颜色。 iOS, swift

转载 作者:可可西里 更新时间:2023-11-01 00:20:45 25 4
gpt4 key购买 nike

我正在尝试更改 iOS 集群注释 mapkit 的默认颜色,swift。

这可能吗?我可以更改单个注释,但不能更改集群。

下面是我的代码。

@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
}

最佳答案

使用markerTintColor

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

例如

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
}

关于ios - 更改市场中集群注释的颜色。 iOS, swift ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47912995/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com