MKPinAnnotationView:有三种颜色可用? [英] MKPinAnnotationView: Are there more than three colors available?

查看:115
本文介绍了MKPinAnnotationView:有三种颜色可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据苹果文档,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 中使用它们:

- (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:有三种颜色可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆