我没有工作InterfaceBuilder.
我有一个实例MKAnnotationView与setDraggable上YES,在我的MKMapView我的标注视图显示,我可以将它拖放.
如何执行放置操作时执行方法?在这个方法中,我需要我的注释视图的新协调.
常规注释引脚的原点位于底部中间,因此引脚始终指向同一位置.
但是当我添加自定义图像时,它的原点是图像的中心,所以每次放大或缩小,我的图像底部指向不同的位置.

在这里我的别针应该指向巴黎的中心但是

但是当我放大时,我的图钉的底部并没有指向巴黎的中心.
我正在尝试CGRect.origin但没有得到任何有用的东西.
这是我的代码:
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView * customPinView = [[MKAnnotationView alloc] init];
UIImage * img = [UIImage imageNamed:@"waterPin.png"] ;
CGRect resizeRect;
resizeRect.size.height = 40;
resizeRect.size.width = 40;
resizeRect.origin = (CGPoint){0.0f, 0.0f};
UIGraphicsBeginImageContext(resizeRect.size);
[img drawInRect:resizeRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
customPinView.image = resizedImage;
return customPinView;
}
Run Code Online (Sandbox Code Playgroud)