9

I create a custom MKAnnoationView as follows:

- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
    static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
    MKAnnotationView* customPinView = [[MKAnnotationView alloc]
                                           initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];

    UIImage *pinImage = [PowerPlantAnnotation getAnnotationImageForEnergySource:((PowerPlantAnnotation*)annotation).energySource];
    customPinView.image = pinImage;
    return customPinView;
}

I get the image that I want positioned more or less in the right spot, but not quite. My image looks like this:

enter image description here

I want the bottom point of the tear drop to point to my annotation map coordinate, like the standard pin view points to the map coordinate. How can I accomplish this? Currently it looks a bit more like my image is centered on the map coordinate.

Darren
  • 10,091
  • 18
  • 65
  • 108

1 Answers1

15

By default annotation view center is placed at the annotation coordinate. To adjust view position set its centerOffset property:

annotationView.centerOffset = CGPointMake(0.0f, -annotationViewHeight/2);
Vladimir
  • 170,431
  • 36
  • 387
  • 313
  • in this case. the center of the view aligns at the exact coordinate position. The base of the pin of should be at the coordinate for accuracy. – carbonr May 27 '16 at 12:16