Skip to content

Instantly share code, notes, and snippets.

@briandw
Created June 24, 2013 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briandw/5851387 to your computer and use it in GitHub Desktop.
Save briandw/5851387 to your computer and use it in GitHub Desktop.
rantlab 1.4
- (void)wiggleFromPath:(CGPathRef)path target:(CGPoint)target amount:(CGFloat)amount
{
CGPoint middle = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds));
CGPathRef endPath = [RLArrowView createPathWithArrowFromPoint:middle
toPoint:target
tailWidth:2.0
headWidth:10.0
headLength:20.0
wiggle:amount];
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];
animation.duration = 0.1;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.repeatCount = 0;
animation.autoreverses = NO;
animation.fromValue = (__bridge id)path;
animation.toValue = (__bridge id)endPath;
[arrow addAnimation:animation forKey:@"animatePath"];
arrow.path = endPath;
} completionHandler:^{
if (fabs(amount)>0.02) [self wiggleFromPath:endPath target:target amount:amount*-0.7];
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment