Wednesday 15 January 2020

UIPanGestureRecognizer do something immediately when touched

I am new to ios, so I apologize in advance if I am missing something obvious.

I am creating a puzzle where I would like the individual puzzle pieces to increase in size on touch and decrease on letting go.

Currently I have:

-(IBAction)handlePan:(UIPanGestureRecognizer *)recognizer{
  if(recognizer.state == UIGestureRecognizerStateBegan)
  else if(recognizer.state == UIGestureRecognizerStateEnded)
}

The puzzle piece increases size when the pan begins (which is also when the statebegan) and decreases in size when the pan ends (as expected). I would like the size to increase once the user has touched the piece and before the puzzle piece moves. This is seen in Words With Friends when selecting a tile.

I have tried

-(IBAction)handleTap:(UITapGestureRecognizer *)recognizer{
  if(recognizer.state == UIGestureRecognizerStateBegan)
  else if(recognizer.state == UIGestureRecognizerStateEnded)
}

This will increase the puzzle piece only after the finger has lifted.

MY QUESTION:

Is there a way to increase the size of a puzzle piece once the finger has touched the puzzle piece and then continue with the pan gesture.

Thank you in advance.



from UIPanGestureRecognizer do something immediately when touched

No comments:

Post a Comment