更改 MKPinAnnotationView 组的颜色

发布于 2024-09-01 21:21:45 字数 91 浏览 2 评论 0原文

我在 MapView 中有几个注释引脚(大约 700)。有什么方法可以从 UITableView 中选择一行并更改一组引脚的颜色?假设每一行代表一组引脚..提前谢谢您!

I have several annotation pins (aprox 700) in a MapView. Is there any way I can select from an UITableView a row and change the color of a group of pins? Lets say each row representing a group of pins.. Thank you in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千紇 2024-09-08 21:21:45

您可以在 MKMapViewDelegate 方法 mapView:viewForAnnotation: 中设置图钉颜色。如果您使用MKPinAnnotationView,您只能使用三种颜色(红色、绿色、紫色),如果您有很多引脚,则这种颜色非常有效。

如果需要,您可以返回一个自定义视图,可能是一个 UIImageView,它可以是您喜欢的任何颜色。

在 tableView 中设置值:这取决于您。我可能会将它传递到我的自定义注释对象中。

如果要更改现有视图,可以在创建视图时将视图保存在 NSSet 或其他集合类中,或者可以删除注释对象并将它们重新添加到地图中。

You set your pin colours in the MKMapViewDelegate method mapView:viewForAnnotation:. If you use MKPinAnnotationView, you are limited to three colours (red, green purple), which is efficient if you have lots of pins.

If you want, you can return a custom view, possibly a UIImageView, which can be any colour you like.

Setting the values in a tableView: that's up to you. I'd probably pass it in my custom annotation object.

If you want to change an existing view, you could save the views in a NSSet or other collection class as you create them, or you could remove the annotation objects and re-add them to your map.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文