How many point move in pinch action?

78 Views Asked by At

Using the following method to detect how many point move in pinch action (using UIPinchGestureRecognizer), I have to get the value of point move the view in iOS device screen.

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

}
1

There are 1 best solutions below

1
p t On

Using following 02 delegate method to getting how many point move in pinch action., before creating one global variable oldPoint

var oldPoint = CGPoint()

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        print("touchesBegan")


        let touch : UITouch = touches.first!
        self.oldPoint = touch.location(in: self.viewAnimate)
    }

    override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
        print("touchesMoved")
        StartRecording()

        let touch : UITouch = touches.first!
        let newPoint = touch.location(in: self.viewPinch)

        print("oldPoint : \(oldPoint)")
        print("newPoint : \(newPoint)")
}

and you will be given output log is,

touchesBegan
touchesMoved
oldPoint : (54.0, 55.0)
newPoint : (52.0, 52.0)
touchesMoved
oldPoint : (54.0, 55.0)
newPoint : (52.0, 51.0)
touchesMoved
oldPoint : (54.0, 55.0)
newPoint : (52.0, 49.0)
touchesMoved
oldPoint : (54.0, 55.0)
newPoint : (52.0, 48.0)