Changing pin color MKMapView

ios, mkmapview, mkpinannotationview

Solution

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation 
  {
    MKPinAnnotationView *annView=[[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"pin"];
    annView.pinColor = MKPinAnnotationColorGreen;
    return annView;
  }

Problem

I add annotations to my map in this way: ``` MyAnnotation *annotationPoint2 = [[MyAnnotation alloc] init]; annotationPoint2.coordinate = anyLocation; annotationPoint2.title = [NSString stringWithFormat:@"%@", obj]; annotationPoint2.subtitle = @""; //or set to nil annotationPoint2.keyValue = [NSString stringWithFormat:@"%@", key]; [mapPins addAnnotation:annotationPoint2]; ``` The pins are all red, and I would like them all green. How can I change the color? I have tried the following, but it still gives a red mark: ``` annotationPoint2.pinColor = MKPinAnnotationColorGreen; ```

Original source