UIButton TouchUpInside Touch Location

前端 未结 2 1636
滥情空心
滥情空心 2020-12-05 02:23

So I have a large UIButton, it is a UIButtonTypeCustom, and the button target is called for UIControlEventTouchUpInside. My question

2条回答
  •  醉梦人生
    2020-12-05 02:55

    For Swift 3.0:

    @IBAction func buyTap(_ sender: Any, forEvent event: UIEvent) 
    {
           let myButton:UIButton = sender as! UIButton
           let touches: Set? = event.touches(for: myButton)
           let touch: UITouch? = touches?.first
           let touchPoint: CGPoint? = touch?.location(in: myButton)
           print("touchPoint\(touchPoint)")  
    }
    

提交回复
热议问题