我使用 UIPanGestureRecognizer 将 CALayer 从一个 UIView 拖到另一个。在 UIGestureRecognizerState.Changed 方法中,我调用移动 CALayer
var touchLocation = recognizer.locationInView(recognizer.view)
self.panForTranslation(touchLocation)
但是 touchLocation 返回的是 CALayers 相对于它的框架的位置,而不是屏幕坐标。
如何获取手指在屏幕上的确切点的 UITouch 位置?
最佳答案
试试这个:
var touchLocation = recognizer.locationInView(recognizer.view.window)
self.panForTranslation(touchLocation)
关于ios - 在 Swift 的手势识别器中获取触摸窗口坐标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30657832/