iphonecocoa-touchmapkitmkpinannotationview

MKPinAnnotationView: Are there more than three colors available?


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.


Solution

  • You might find the following images useful:

    alt text alt text alt text alt text

    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];
        }
        // ...