Posted By

zamza726 on 03/16/11


Tagged

expand shrink Gesture


Versions (?)

MyPinchGesture


 / Published in: Objective C
 

Cascade to 4 mode: Expand horizontally, Expand vertically, Shrink horizontally, Shrink vertially

  1. - (void)handleMyPinchFrom:(UIPinchGestureRecognizer *)recognizer {
  2. /* Add Blocking Code here~!
  3. // if ([detailCellLayer.sublayers count]) {
  4. // return;
  5. // }
  6. */
  7. if(recognizer.state == UIGestureRecognizerStateBegan) {
  8. originP = [recognizer locationOfTouch:0 inView:recognizer.view]; //Save original point
  9. return;
  10. }
  11.  
  12. if(recognizer.state == UIGestureRecognizerStateEnded) {
  13.  
  14. CGPoint point = [recognizer locationOfTouch:0 inView:recognizer.view];
  15.  
  16. NSLog(@"PINCH %f,%f -> %f,%f : scale: %f",originP.x,originP.y,point.x,point.y,recognizer.scale);
  17.  
  18. if (recognizer.scale > 1) {
  19. if (abs(originP.x - point.x) > 60 ) {
  20. NSLog(@"Expand Horizontal");
  21.  
  22. }
  23. else if (abs(originP.y - point.y) > 60 ) {
  24. NSLog(@"Expand Vertical");
  25. }
  26. }
  27. else { //shrink
  28. if (abs(originP.x - point.x) > 60 ) {
  29. NSLog(@"Shrink Horizontal");
  30. }
  31. else if (abs(originP.y - point.y) > 60 ) {
  32. NSLog(@"Shrink Vertical");
  33. }
  34. }
  35.  
  36. }
  37. }

Report this snippet  

You need to login to post a comment.