Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在不更改Swift中默认位置pin的情况下更改MapKit中的markerTintColor?_Ios_Swift_Annotations_Mapkit_Swift4 - Fatal编程技术网

Ios 如何在不更改Swift中默认位置pin的情况下更改MapKit中的markerTintColor?

Ios 如何在不更改Swift中默认位置pin的情况下更改MapKit中的markerTintColor?,ios,swift,annotations,mapkit,swift4,Ios,Swift,Annotations,Mapkit,Swift4,我有MkMarkerNotationView来更改地图上图钉的颜色 func mapView(_ MapView:MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?{ let view = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: "pin") view.markerTintColor = .blue

我有MkMarkerNotationView来更改地图上图钉的颜色

func mapView(_ MapView:MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?{

    let view = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: "pin")

    view.markerTintColor = .blue

    return view

}
但是,当我启动我的应用程序时,我的defoult位置标记变为。 如何在不更改此标记的情况下更改pin? 查看位置的代码也很简单

 func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
    self.MapView.showsUserLocation = true
}

谢谢你的回答!:)

在方法中,检查注释对象是否是
MKUserLocation
的实例。如果是,则返回nil以保留标准用户位置注释视图


(用于
mapView(uuquo;viewFor:)
的文档对此进行了解释。)

在您的方法中,检查注释对象是否是
MKUserLocation
的实例。如果是,则返回nil以保留标准用户位置注释视图


(用于
mapView(u:viewFor:)
的文档对此进行了解释。)

您可以检查注释是否为如下所示的用户位置:

func mapView(_ MapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
    if annotation is MKUserLocation {
        return nil
    }

    let view = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: "pin")
    view.markerTintColor = .blue
    return view
}

您可以检查注释是否为如下所示的用户位置:

func mapView(_ MapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
    if annotation is MKUserLocation {
        return nil
    }

    let view = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: "pin")
    view.markerTintColor = .blue
    return view
}