如何在Swift中将用户位置注释设置为默认注释?

问题描述 投票:0回答:1

最近,我将主视图控制器设置为MKMapViewDelegate,该控件允许它向我的地图添加自定义注释。我正在尝试自定义除用户位置注释(蓝点)以外的所有注释。

当我在MKMapViewDelegate中重写“视图:注释”以使每个注释具有不同的图像时,甚至用户位置注释也会更改。

反正有将用户位置注释还原为默认注释吗?

enter image description here

谢谢!

swift uikit mapkit
1个回答
0
投票

Swift 5.0

在函数顶部放置一个检查以忽略userLocation:

   func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
        guard annotation as? MKUserLocation != mapView.userLocation else { return }
© www.soinside.com 2019 - 2024. All rights reserved.