2015-11-02 58 views
0

有沒有辦法改變註釋rightCalloutAccessory的色調顏色,而不改變mapView的色調顏色?如何更改Mapbox上rightCalloutAccessory的色調?

例如,我想將地圖着色顏色設置爲白色,以便用戶當前位置和右下角的信息圖標爲白色,但我希望註釋calloutAccessory爲藍色。

回答

0

你會想mapView:rightCalloutAccessoryViewForAnnotation:,它可以像這樣使用:您可以通過調用MKMapViewDelegate協議的功能做到這一點

- (UIView *)mapView:(__unused MGLMapView *)mapView rightCalloutAccessoryViewForAnnotation:(__unused id<MGLAnnotation>)annotation 
{ 
    UIButton *rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeInfoLight]; 
    rightCalloutAccessoryView.tintColor = [UIColor blueColor]; 

    return rightCalloutAccessoryView; 
} 
-1

我想你想改變註解視圖的色調顏色。

func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { 
    var annotationView = mapView.dequeueReusableAnnotationViewWithIdentifier("annotationView") as? MKPinAnnotationView 

    if annotationView == nil { 
     annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "annotationView") 
    } 

    annotationView?.canShowCallout = true 
    annotationView?.rightCalloutAccessoryView = UIButton(type: UIButtonType.DetailDisclosure) 
    annotationView?.rightCalloutAccessoryView?.tintColor = UIColor.whiteColor() 

    return annotationView 
} 
+0

你的回答是MapKit,而問題要求Mapbox。但絕對是正確的。 – friedbunny