MKPinAnnotationView:是否有超过三种颜色可用?
根据 Apple 文档,MKPinAnnotationView 的图钉颜色有红色、绿色和紫色。 还有什么办法可以得到其他颜色吗? 我在文档中没有找到任何内容。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
根据 Apple 文档,MKPinAnnotationView 的图钉颜色有红色、绿色和紫色。 还有什么办法可以得到其他颜色吗? 我在文档中没有找到任何内容。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(9)
更多 ;)
以及原始图像:
和代码:
some more ;)
And the original ones :
And the code:
您可能会发现以下图像很有用:
以及在 viewForAnnotation 中使用它们的代码:
You might find the following images useful:
and the code to use them in viewForAnnotation:
您可以使用
ZSPinAnnotation
使用指定的UIColor
动态创建注释图钉:https://github.com/nnhubbard/ZSPinAnnotationYou could use
ZSPinAnnotation
to create annotation pins on the fly with a specifiedUIColor
: https://github.com/nnhubbard/ZSPinAnnotation我喜欢 Yonel 的答案,但只是一个头向上,当您创建自定义 MKAnnotationView 时,您必须手动分配偏移量。 对于 Yonel 提供的图像:(如果您不需要其中之一,则可以省略 calloutButton 内容)
I like Yonel's Answer but just a heads up, when you create a custom MKAnnotationView, you'll have to manually assign the offset. For the images Yonel provided: (you can leave out the calloutButton stuff if you don't need one of those)
这是带有阴影的引脚的 PSD,其大小为 @2x。
http://dl.dropbox.com/u/5622711/ios-pin.psd
使用此 PSD 来呈现您想要的任何颜色:)
我不将此 PSD 归功于我。 我刚刚从 http://www.teehanlax.com 获取它/downloads/iphone-4-guid-psd-retina-display/ 他们做得非常出色!
And here is the PSD for the pin with shadow and its in @2x size.
http://dl.dropbox.com/u/5622711/ios-pin.psd
Use this PSD for any color you want :)
I take no credit for this PSD. I just grabbed it from http://www.teehanlax.com/downloads/iphone-4-guid-psd-retina-display/ They have done a wonderful job!
在 iOS 9 中,
pinTintColor
已添加到MKPinAnnotationView
中,允许您为图钉颜色提供UIColor
。With iOS 9,
pinTintColor
has been added toMKPinAnnotationView
, allowing you to supply aUIColor
for the pin color.如果您使用引脚掉落动画,则所发布的解决方案都不能 100% 工作。 Cannonade 的解决方案非常巧妙,因为它允许别针仍然具有两种末端(掉落时的尖点和带有圆形纸波纹的一端),但不幸的是,当别针弹起时,可以看到原始别针头颜色它击中了地图。 约内尔的解决方案是替换整个图钉图像,这意味着图钉在击中地图之前就随着圆形纸波纹落下!
Neither of the posted solutions work 100% if you are using the pin drop animation. Cannonade's solution is very neat because it allows the pin to still have both kinds of ends (the sharp point when falling and the one with the circular paper ripple) but unfortunately a glimpse of the original pin head colour can be seen when the pin bounces as it hits the map. yonel's solution of replacing the whole pin image means the pin falls with the circular paper ripple before it's even hit the map!
我尝试了这种方式,似乎没问题...
使用完整的引脚图像...作为 yonel 的示例
I tried this way and it seems to be ok...
using the complete pin image... as the yonel example
如果它不在文档中,那么很可能不会,如果您愿意,您可以使用 mkannotationview 并拥有自己的图像
If it's not in the docs then most probably not, you cAn use mkannotationview and have ur own image if u wish though