使用 Mapbox iOS SDK 时如何设置标注视图的背景颜色?
How do I set the callout view’s background color when using the Mapbox iOS SDK?
我正在使用 Mapbox SDK 构建地图应用程序。以下是我在地图上显示注释和 auto-show 标题弹出窗口的方式:
[myAnnotation setCoordinate:touchMapCoordinate];
myAnnotation.title = @"This Is A Title";
[self.mapView addAnnotation:myAnnotation];
[self.mapView selectAnnotation:myAnnotation animated:YES];
目前,标题以标准白色背景弹出。但是,我希望标题有黑色背景,因为我使用光照贴图并希望弹出窗口更加突出。我该怎么做?
自 Mapbox iOS SDK v3.2.0 起,默认标注视图未公开,您无法更改其外观超过 adding accessory views and title text。
相反,您应该提供符合 MGLCalloutView protocol, then display it with your map using the MGLMapViewDelegate method -mapView:calloutForAnnotation:.
的自定义标注视图
请参阅 this example for a working implementation in both Objective-C and Swift. The default callout view uses SMCalloutView,您可以相对轻松地改编此示例以也使用它。
我正在使用 Mapbox SDK 构建地图应用程序。以下是我在地图上显示注释和 auto-show 标题弹出窗口的方式:
[myAnnotation setCoordinate:touchMapCoordinate];
myAnnotation.title = @"This Is A Title";
[self.mapView addAnnotation:myAnnotation];
[self.mapView selectAnnotation:myAnnotation animated:YES];
目前,标题以标准白色背景弹出。但是,我希望标题有黑色背景,因为我使用光照贴图并希望弹出窗口更加突出。我该怎么做?
自 Mapbox iOS SDK v3.2.0 起,默认标注视图未公开,您无法更改其外观超过 adding accessory views and title text。
相反,您应该提供符合 MGLCalloutView protocol, then display it with your map using the MGLMapViewDelegate method -mapView:calloutForAnnotation:.
的自定义标注视图请参阅 this example for a working implementation in both Objective-C and Swift. The default callout view uses SMCalloutView,您可以相对轻松地改编此示例以也使用它。