TAGS :Viewed: 5 - Published at: a few seconds ago

[ how to change color of pin for mapview iphone ]

MyAnnotation *ann1 = [[MyAnnotation alloc] init];

  ann1.coordinate =region.center;


  [mapView addAnnotation:ann1];

right now its purple i want red

Answer 1


Implement MKMapViewDelegate protocol callback and set the implementing class as the map view delegate

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation {

    MKPinAnnotationView *newAnnotationPin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"simpleAnnotation"] autorelease];
    newAnnotationPin.pinColor = MKPinAnnotationColorRed; // Or Red/Green
    return newAnnotation;

}