Guest User

Untitled

a guest
Jan 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
  2.  
  3. UITouch *touch = [[event allTouches] anyObject];
  4.  
  5. NSLog(@"[touch view]:::%@",[touch view]);
  6.  
  7. touchStart = [[touches anyObject] locationInView:testVw];
  8. isResizingLR = (testVw.bounds.size.width - touchStart.x < kResizeThumbSize && testVw.bounds.size.height - touchStart.y < kResizeThumbSize);
  9. isResizingUL = (touchStart.x <kResizeThumbSize && touchStart.y <kResizeThumbSize);
  10. isResizingUR = (testVw.bounds.size.width-touchStart.x < kResizeThumbSize && touchStart.y<kResizeThumbSize);
  11. isResizingLL = (touchStart.x <kResizeThumbSize && testVw.bounds.size.height -touchStart.y <kResizeThumbSize);
  12. }
  13.  
  14. - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
  15. CGPoint touchPoint = [[touches anyObject] locationInView:testVw];
  16. CGPoint previous=[[touches anyObject]previousLocationInView:testVw];
  17.  
  18.  
  19.  
  20.  
  21. float deltaWidth = touchPoint.x-previous.x;
  22. float deltaHeight = touchPoint.y-previous.y;
  23.  
  24. NSLog(@"CVTM:%@",NSStringFromCGRect(testVw.frame));
  25.  
  26.  
  27. if (isResizingLR) {
  28. testVw.frame = CGRectMake(testVw.frame.origin.x, testVw.frame.origin.y,touchPoint.x + deltaWidth, touchPoint.y + deltaWidth);
  29. }
  30. if (isResizingUL) {
  31. testVw.frame = CGRectMake(testVw.frame.origin.x + deltaWidth, testVw.frame.origin.y + deltaHeight, testVw.frame.size.width - deltaWidth, testVw.frame.size.height - deltaHeight);
  32. }
  33. if (isResizingUR) {
  34. testVw.frame = CGRectMake(testVw.frame.origin.x ,testVw.frame.origin.y + deltaHeight, testVw.frame.size.width + deltaWidth, testVw.frame.size.height - deltaHeight);
  35. }
  36. if (isResizingLL) {
  37. testVw.frame = CGRectMake(testVw.frame.origin.x + deltaWidth ,testVw.frame.origin.y , testVw.frame.size.width - deltaWidth, testVw.frame.size.height + deltaHeight);
  38. }
  39.  
  40. if (!isResizingUL && !isResizingLR && !isResizingUR && !isResizingLL) {
  41. testVw.center = CGPointMake(testVw.center.x + touchPoint.x - touchStart.x,testVw.center.y + touchPoint.y - touchStart.y);
  42. }
  43.  
  44. }
Add Comment
Please, Sign In to add comment