如何在Mapbox上更改rightCalloutAccessory的色调?

时间:2015-11-02 15:50:12

标签: ios mapbox

有没有办法更改注释rightCalloutAccessory的色调颜色,而不更改mapView的色调?

例如,我想将地图色调颜色设置为白色,以便用户当前位置和右下角的信息图标为白色,但我想要注释{{1}成为蓝色。

2 个答案:

答案 0 :(得分:0)

您需要mapView:rightCalloutAccessoryViewForAnnotation:,可以这样使用:

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

    return rightCalloutAccessoryView;
}

答案 1 :(得分:-1)

我认为您想要更改注释视图的色调颜色。您可以通过调用MKMapViewDelegate协议的功能来执行此操作:

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
}