如何设置MKPinAnnotation,以便图像的底部指向位置而不是图像的中心 [英] How to set MKPinAnnotation so that bottom of image points to location instead of center of image

查看:86
本文介绍了如何设置MKPinAnnotation,以便图像的底部指向位置而不是图像的中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何移动大头针图像,使图像的底部指向该位置(如默认大头针).当前,图像中心指向该位置(旧金山).

How can I move the pin image so that the bottom of the image points to the location (like the default pin). Currently the center of the image points to that location (San Francisco).

推荐答案

您需要计算要偏移的像素数,然后设置centerOffset属性.

You'll need to calculate the number of pixels to offset and then set the centerOffset property.

默认情况下,注释视图的中心点位于 关联注释的坐标点.你可以用这个 属性以根据需要重新定位注释视图.这个x和y 偏移值以像素为单位.正偏移值会移动 注释视图向下和向右移动,而负值将其移动 向上和向左.

By default, the center point of an annotation view is placed at the coordinate point of the associated annotation. You can use this property to reposition the annotation view as needed. This x and y offset values are measured in pixels. Positive offset values move the annotation view down and to the right, while negative values move it up and to the left.

这篇关于如何设置MKPinAnnotation,以便图像的底部指向位置而不是图像的中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆