在framework中引入QuatrtzCore.framework,在头文件中需要
#import <QuartzCore/QuartzCore.h>
CATransition *animation =[[CATransitionanimation alloc]init];
[animation setDuration:duration];
[animation setFillMode:model];
[animation setType:type];
[animation setSubtype:subtype];
animation.timingFunction = UIViewAnimationCurveEaseInOut;
[animation setRemovedOnCompletion:completion];
[self.window.layer addAnimation:animation forKey:key];
UIBezierPath *movePath = [UIBezierPath bezierPath];
[movePath moveToPoint:CGPointMake(10.0, 10.0)];
[movePath addQuadCurveToPoint:CGPointMake(100, 300) controlPoint:CGPointMake(300, 100)];
CAKeyframeAnimation * posAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
posAnim.path = movePath.CGPath;
posAnim.removedOnCompletion = YES;
CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)];
scaleAnim.removedOnCompletion = YES;
CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"];
opacityAnim.fromValue = [NSNumber numberWithFloat:1.0];
opacityAnim.toValue = [NSNumber numberWithFloat:0.1];
opacityAnim.removedOnCompletion = YES;
CAAnimationGroup *animGroup = [CAAnimationGroup animation];
animGroup.animations = [NSArray arrayWithObjects:posAnim, scaleAnim, opacityAnim, nil];
animGroup.duration = 1;
[imgView.layer addAnimation:animGroup forKey:nil];
//移动
CABasicAnimation *animation =
[CABasicAnimation animationWithKeyPath:@”position”];
[animation setFromValue:[NSValue valueWithPoint:startPoint]];
[animation setToValue:[NSValue valueWithPoint:endPoint]];
[animation setDuration:5.0];
[layer setPosition:endpoint];
[layer addAnimation:animation forKey:nil];