How to get direction in UIPanGesture and increase/decrease or scale view accordingly

StackOverflow https://stackoverflow.com/questions/8558233

  •  20-03-2021
  •  | 
  •  

سؤال

As I am new to this field. I searched a lot over net but cant find anything relevant. I am trying for UIPinchGestureRecognizer where once the user Pinch horizontally view should scale only horizontally, similarly for vertical also and if user does it diagonally it should scale in both directions. Currently my view is scaling in both direction as I am doing

CGAffineTransform newTransform = CGAffineTransformScale(currentTransform, scale, scale);

[[(UIPinchGestureRecognizer*)sender view] setTransform:newTransform];

Please help me on same.

Thanks in advance..

هل كانت مفيدة؟

المحلول

Subclass UIGestureRecognizer an implement:

– touchesBegan:withEvent:
– touchesMoved:withEvent:
– touchesEnded:withEvent:
– touchesCancelled:withEvent:

In these delegates to your custom code for touch gesture.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top