单击 UIImageView 时如何获取触摸位置?
How to get touch location when clicking a UIImageView?
我希望能够确定用户在 Swift 中单击 UIImageView 的 x,y 位置。
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if let touch = touches.first {
let position = touch.location(in: imageView)
print(position.x)
print(position.y)
}
}
我希望能够确定用户在 Swift 中单击 UIImageView 的 x,y 位置。
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if let touch = touches.first {
let position = touch.location(in: imageView)
print(position.x)
print(position.y)
}
}