Don't like ads? PRO users don't see any ads ;-)
Guest

animateFirstTouchAtPoint

By: a guest on Aug 2nd, 2012  |  syntax: Objective C  |  size: 0.96 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
  2.        
  3. // We only support single touches, so anyObject retrieves just that touch from touches
  4.         UITouch *touch = [touches anyObject];
  5.                        
  6.         /// Animate the first touch
  7.         CGPoint touchPoint = [touch locationInView:myParentView];
  8.        
  9.         //started animating
  10.         [self animateFirstTouchAtPoint:touchPoint];
  11. }
  12.  
  13.  
  14. - (void)animateFirstTouchAtPoint:(CGPoint)touchPoint { 
  15.        
  16. #define GROW_ANIMATION_DURATION_SECONDS 0.15
  17.        
  18.         NSValue *touchPointValue = [NSValue valueWithCGPoint:touchPoint];
  19.         [UIView beginAnimations:nil context:(__bridge_retained void *)touchPointValue];
  20.         [UIView setAnimationDuration:GROW_ANIMATION_DURATION_SECONDS];
  21.         [UIView setAnimationDelegate:self];
  22.         [UIView setAnimationDidStopSelector:@selector(growAnimationDidStop:finished:context:)];
  23.         CGAffineTransform transform = CGAffineTransformMakeScale(1.2f, 1.2f);
  24.         self.transform = transform;
  25.         [UIView commitAnimations];
  26.         touchPointValue = nil;
  27.        
  28. }