Saturday 30 January 2021

Swift - Doing Pinch gesture recognition

 Steps:

1. Create an instance to the pinch gesture class

2. Create a function that performs action

3. Add the gesture recogniser to the created instance

self.imageViews.addGestureRecognizer(UIPinchGestureRecognizer(target: self, action: #selector(self.pinchAction(gesture:)))) 

//Creating a function for pinch act

    @objc func pinchAction(gesture:UIPinchGestureRecognizer)

    {

        if let ges = gesture.view

        {

            ges.transform = ges.transform.scaledBy(x: gesture.scale, y: gesture.scale)

            gesture.scale = 1

            

        }

        

    }