您的位置:首页 > 移动开发 > IOS开发

iOS 核心动画合成

2015-06-29 13:31 489 查看
//摇晃

CAKeyframeAnimation * shakeAnima = [CAKeyframeAnimation
animationWithKeyPath:@"transform.rotation"];

// 2.
设置动画属性

[shakeAnima setValues:@[@(12.0f*M_PI/180.0f),
@(-12.0f*M_PI/180.0f),
@(12.0f*M_PI/180.0f),@(0.0f*M_PI/180.0f)]];
shakeAnima.repeatCount=1;



//透明度

CABasicAnimation *opacityAnim = [CABasicAnimation
animationWithKeyPath:@"opacity"];
opacityAnim.toValue = [NSNumber
numberWithFloat:1.0f];
opacityAnim.repeatCount=1;



//大小

CABasicAnimation *anima1=[CABasicAnimation
animationWithKeyPath:@"bounds"];
anima1.toValue=[NSValue
valueWithCGRect:CGRectMake(0,
0, 40,
40)];



//位置

CABasicAnimation *animation2 = [CABasicAnimation
animationWithKeyPath:@"position"];
animation2.fromValue = [NSValue
valueWithCGPoint:CGPointMake(SCREEN_WIDTH-75-30, -30)];
animation2.toValue = [NSValue
valueWithCGPoint:btn.center];

animation2.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseOut];



//动画组合

animationGroup = [CAAnimationGroup
animation];

animationGroup.animations =
@[opacityAnim, shakeAnima,anima1,animation2];

animationGroup.fillMode =
kCAFillModeForwards;

animationGroup.removedOnCompletion=FALSE;

animationGroup.delegate=self;

animationGroup.duration =
1;

[self.layer
addAnimation:animationGroup
forKey:@"group"];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: