有没有办法更改注释rightCalloutAccessory
的色调颜色,而不更改mapView
的色调?
例如,我想将地图色调颜色设置为白色,以便用户当前位置和右下角的信息图标为白色,但我想要注释{{1}成为蓝色。
答案 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
}