本文介绍了MKPinAnnotationView:是否有超过三种颜色可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据 Apple 文档,MKPinAnnotationView 的引脚颜色有红色、绿色和紫色.有没有办法获得其他颜色?我在文档中什么也没找到.
According to the Apple docs, MKPinAnnotationView's pin color is available in red, green and purple. Is there any way to get other colors also? I've found nothing in the docs.
推荐答案
您可能会发现以下图片很有用:
You might find the following images useful:
以及在 viewForAnnotation 中使用它们的代码:
and the code to use them in viewForAnnotation:
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
// ... get the annotation delegate and allocate the MKAnnotationView (annView)
if ([annotationDelegate.type localizedCaseInsensitiveCompare:@"NeedsBluePin"] == NSOrderedSame)
{
UIImage * image = [UIImage imageNamed:@"blue_pin.png"];
UIImageView *imageView = [[[UIImageView alloc] initWithImage:image] autorelease];
[annView addSubview:imageView];
}
// ...
这篇关于MKPinAnnotationView:是否有超过三种颜色可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!