Skip to content

Instantly share code, notes, and snippets.

@briandw
Created Jun 24, 2013
Embed
What would you like to do?
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