简体   繁体   中英

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

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;

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM