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"];
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"];
相关文章推荐
- IOS编程第四版第二章---Managing Memory with ARC
- 【ios开发】关于NSPredicate的详解
- 错误:ld: library not found for -lWeChatSDK
- ios之点语法
- ios自定义NSLog的输出内容
- ios的@property属性和@synthesize属性
- ios内存管理2-对象之间的内存管理
- ios内存管理1-retain和release的简单使用
- ios学习中对于懒加载的个人理解
- ios学习中懒加载的个人理解
- iOs画图 划线的三种方式
- ios画图 划线的两种方式
- iOS IAP恢复
- iOS 隐藏状态栏
- iOS画图 圆形裁剪
- iOS画图 上下文栈的使用
- iOS 对相机及相册的操作
- iOS开发之Xcode6之后不再自动创建Pch预编译文件(解决unknown type name........)
- 画1像素的线
- iOS 如何 理解 代理