【发布时间】:2018-01-11 09:31:58
【问题描述】:
我正在尝试在 ios 设备上移动 UIImageView。我可以移动它,但是偏移量有问题,因为当我单击图像时,我将 ImageView 中心设置为锚点移动点。 如何将触摸屏 CGPOint 设置为移动 UIImageView 的锚点?
override func touchesBegan( . . . ){
location = touch.location(in : self.view)
. . .
imageView.center = location
. . .
}
override func touchesMoved( . . . ){
location = touch.location(in : self.view)
. . .
imageView.center = location
. . .
}
【问题讨论】:
-
您必须在 UIImageView 上的 touchesBegan 期间进行命中测试,以检查触摸在 UIImageView 上的哪个点并记住该偏移量。然后在 touchesMoved 期间,将您的 imageView.center 更改为 touch 加上首次注册的偏移量。
-
我尝试这样做,但无法找到可行的解决方案
标签: ios swift uiimageview