9

我创建了一个自定义的 MKAnnoationView,如下所示:

- (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;
}

我得到了我想要或多或少定位在正确位置的图像,但不完全是。我的图像如下所示:

在此处输入图像描述

我希望泪滴的底点指向我的注释地图坐标,就像标准引脚视图指向地图坐标一样。我怎样才能做到这一点?目前,它看起来更像是我的图像以地图坐标为中心。

4

1 回答 1

15

默认情况下,注释视图中心位于注释坐标处。要调整视图位置,请设置其centerOffset属性:

annotationView.centerOffset = CGPointMake(0.0f, -annotationViewHeight/2);
于 2012-12-12T20:48:09.960 回答