MKPinAnnotationView: Are there more than three colors available?

前端 未结 9 1409

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 do

9条回答
  •  青春惊慌失措
    2020-11-27 10:29

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

提交回复
热议问题