简体   繁体   English

带光环的iPhone MKMapView针

[英]iPhone MKMapView pin with halo

On an MKMapView, you can show the user location. 在MKMapView上,您可以显示用户位置。 Around the blue user location dot is a sort of 'blue halo' to represent the accuracy. 蓝色用户位置点周围是代表“准确性”的一种“蓝色光环”。 How would one go about adding this into my own app, but around a pin? 如何将其添加到我自己的应用程序中,但要花一针钱呢? The location of the pin comes from a Mac that used CoreLocation there, and I already know the accuracy. 引脚的位置来自在那里使用CoreLocation的Mac,我已经知道精度了。 Thanks! 谢谢!

You could simply draw an MKCircle around that pin. 您可以简单地在该引脚周围绘制一个MKCircle。 Assuming you have the center coordinate and the accuracy (the radius of the circle), you could just add an overlay to the map with a call [map addOverlay: [MKCircle circleWithCenterCoordinate: coordinate radius: accuracy]] 假设您具有中心坐标和精度(圆的半径),则可以通过调用[map addOverlay: [MKCircle circleWithCenterCoordinate: coordinate radius: accuracy]]将叠加层添加到地图上

You can then customize the appearance of the circle in MKMapViewDelegate method mapView:viewForOverlay: , where you can create a MKCircleView and return that. 然后,您可以在MKMapViewDelegate方法mapView:viewForOverlay:自定义圆的外观,您可以在其中创建MKCircleView并将其返回。

This wouldn't allow animating, but it would be quite similar to the circle used around the user location. 这将不允许进行动画处理,但它与用户位置周围使用的圆圈非常相似。

You would need to either implement a custom MKAnnotationView subclass, or assign appropriate images to the image property of an existing MKAnnotationView object. 您可能需要实现自定义的MKAnnotationView子类,或者将适当的图像分配给现有MKAnnotationView对象的image属性。 The fancy animated indicator used for the user location is a private class, so you cannot access it directly as a base for your custom behavior. 用于用户位置的精美动画指示器是一个私有类,因此您不能直接将其用作自定义行为的基础。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM