swift -> 按钮 操作 获取 触摸 位置 坐标

touchDragInside  区域内 滑动  等同于 onTouchMove

btn.addTarget(self, action: #selector(xxxxx.touchMoveDrawView), for: .touchDragInside)


    func touchMoveDrawView(sender: AnyObject?,event:UIEvent){
        let button = sender as! UIButton
        let touch:UITouch = (event.touches(for: button)?.first)!
        let location = touch.location(in: button);
        print("x:"+String(describing: location.x)+",y:"+String(describing: location.y));
        
    }

猜你喜欢

转载自mft.iteye.com/blog/2367727