+ // Create the animation's path.
+ CGPathRef path = NULL;
+ CGMutablePathRef mutablepath = CGPathCreateMutable();
+ CGPathMoveToPoint(mutablepath, NULL, startPoint.x, startPoint.y);
+
+ CGPathAddCurveToPoint(mutablepath, NULL,
+ curvePoint1.x, curvePoint1.y,
+ curvePoint2.x, curvePoint2.y,
+ endPoint.x, endPoint.y);
+
+ path = CGPathCreateCopy(mutablepath);
+ CGPathRelease(mutablepath);
+
+ UIImageView* animatedLabel = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"packages.png"]];
+ animatedLabel.tag = 12345;
+ [[[self view] window] addSubview:animatedLabel];
+ [animatedLabel release];
+ CALayer *iconViewLayer = animatedLabel.layer;
+
+ CAKeyframeAnimation *animatedIconAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
+ animatedIconAnimation.removedOnCompletion = YES;
+ animatedIconAnimation.duration = 0.5;
+ animatedIconAnimation.delegate = self;
+ animatedIconAnimation.path = path;
+ animatedIconAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
+ [iconViewLayer addAnimation:animatedIconAnimation forKey:@"animateIcon"];
+
+ // Start the icon animation.
+ [iconViewLayer setPosition:CGPointMake(endPoint.x, endPoint.y)];
+
+ [UIView beginAnimations:nil context:iconViewLayer];
+ [UIView setAnimationDelegate:self];
+ [UIView setAnimationDidStopSelector:@selector(flyAnimationCompleted:finished:context:)];
+ [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
+ [UIView setAnimationDuration:0.5];
+ [animatedLabel setTransform:CGAffineTransformMakeScale(0.3, 0.3)];
+ [UIView commitAnimations];