2

This is mostly just to help future users. If you want more than the 3 basic pin colors that come with MkPinAnnotation, follow these steps.

Download ZSPinAnnotation.m and .h from here You only need these two files, put the .m and .h file into your current project. Now then. I've commented out the old way and substituted the new way

In the header

#import "ZSPinAnnotion.h"

then at the bottom

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[Location class]]) {  

    static NSString *identifier = @"Location";
    //MKPinAnnotationView *annotationView = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
    ZSPinAnnotation *annotationView = (ZSPinAnnotation *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
     //annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
        annotationView = [[ZSPinAnnotation alloc] initWithAnnotation:annotation reuseIdentifier:identifier];

        annotationView.enabled = YES;
        annotationView.canShowCallout = YES;            
        annotationView.annotationColor=[UIColor greenColor];  //you can set quite a few colors this way, or look at the examples for how to do RGB.  Much thanks to Nic Hubbard and Zed Said Studio
user2057434
  • 127
  • 2
  • 7

0 Answers0