在IPHONE上使用标准core animation调用
- (void) action: (id) sender
{
//self.navigationItem.rightBarButtonItem = nil;
// Adapted from Lucas Newman's sample code (www.lucasnewman.com)
UIView *theView = [self.view viewWithTag:101];
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:ANIMATION_DURATION] forKey:kCATransactionAnimationDuration];
// scale it down
CABasicAnimation *shrinkAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
shrinkAnimation.delegate = self;
shrinkAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
shrinkAnimation.toValue = [NSNumber numberWithFloat:0.0];
[[theView layer] addAnimation:shrinkAnimation forKey:@"shrinkAnimation"];
// fade it out
CABasicAnimation *fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
fadeAnimation.toValue = [NSNumber numberWithFloat:0.0];
fadeAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[[theView layer] addAnimation:fadeAnimation forKey:@"fadeAnimation"];
// make it jump a couple of times
CAKeyframeAnimation *positionAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
CGMutablePathRef positionPath = CGAutorelease(CGPathCreateMutable());
CGPathMoveToPoint(positionPath, NULL, [theView layer].position.x, [theView layer].position.y);
CGPathAddQuadCurveToPoint(positionPath, NULL, [theView layer].position.x, - [theView layer].position.y, [theView layer].position.x, [theView layer].position.y);
CGPathAddQuadCurveToPoint(positionPath, NULL, [theView layer].position.x, - [theView layer].position.y * 1.5, [theView layer].position.x, [theView layer].position.y);
CGPathAddQuadCurveToPoint(positionPath, NULL, [theView layer].position.x, - [theView layer].position.y * 1.25, [theView layer].position.x, [theView layer].position.y);
positionAnimation.path = positionPath;
positionAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[[theView layer] addAnimation:positionAnimation forKey:@"positionAnimation"];
[CATransaction commit];
}
- (void) action: (id) sender
{
//self.navigationItem.rightBarButtonItem = nil;
// Adapted from Lucas Newman's sample code (www.lucasnewman.com)
UIView *theView = [self.view viewWithTag:101];
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:ANIMATION_DURATION] forKey:kCATransactionAnimationDuration];
// scale it down
CABasicAnimation *shrinkAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
shrinkAnimation.delegate = self;
shrinkAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
shrinkAnimation.toValue = [NSNumber numberWithFloat:0.0];
[[theView layer] addAnimation:shrinkAnimation forKey:@"shrinkAnimation"];
// fade it out
CABasicAnimation *fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
fadeAnimation.toValue = [NSNumber numberWithFloat:0.0];
fadeAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[[theView layer] addAnimation:fadeAnimation forKey:@"fadeAnimation"];
// make it jump a couple of times
CAKeyframeAnimation *positionAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
CGMutablePathRef positionPath = CGAutorelease(CGPathCreateMutable());
CGPathMoveToPoint(positionPath, NULL, [theView layer].position.x, [theView layer].position.y);
CGPathAddQuadCurveToPoint(positionPath, NULL, [theView layer].position.x, - [theView layer].position.y, [theView layer].position.x, [theView layer].position.y);
CGPathAddQuadCurveToPoint(positionPath, NULL, [theView layer].position.x, - [theView layer].position.y * 1.5, [theView layer].position.x, [theView layer].position.y);
CGPathAddQuadCurveToPoint(positionPath, NULL, [theView layer].position.x, - [theView layer].position.y * 1.25, [theView layer].position.x, [theView layer].position.y);
positionAnimation.path = positionPath;
positionAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[[theView layer] addAnimation:positionAnimation forKey:@"positionAnimation"];
[CATransaction commit];
}