【发布时间】:2017-03-01 05:32:55
【问题描述】:
我正在尝试获取点击按钮的 (x,y) 位置。我找到了答案,但它们不适用于 Swift 2.3。 有什么建议? 这就是我尝试过的:
@IBAction func buttonTapped(sender: AnyObject, forEvent event: UIEvent) {
let buttonView = sender as! UIView;
// get any touch on the buttonView
if let touch = event.touchesForView(buttonView) as? UITouch{
// print the touch location on the button
print(touch.locationInView(buttonView))
}
}
【问题讨论】:
-
您已经尝试过的解决方案中的任何代码?
标签: ios swift uibutton ibaction uitouch