首页 > 其他 > 详细

CABasicAnimation 动画组合

时间:2015-05-01 11:59:14      阅读:222      评论:0      收藏:0      [点我收藏+]

使用CAAnimationGroup类进行复数动画的组合。代码如下:

/* 动画1(在X轴方向移动) */
CABasicAnimation *animation1 =
    [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
 
// 终点设定
animation1.toValue = [NSNumber numberWithFloat:80];; // 終点
 
 
/* 动画2(绕Z轴中心旋转) */
CABasicAnimation *animation2 =
    [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
 
// 设定旋转角度
animation2.fromValue = [NSNumber numberWithFloat:0.0]; // 开始时的角度
animation2.toValue = [NSNumber numberWithFloat:4 * M_PI]; // 结束时的角度
 
 
/* 动画组 */
CAAnimationGroup *group = [CAAnimationGroup animation];
 
// 动画选项设定
group.duration = 3.0;
group.repeatCount = 1;
 
// 添加动画
group.animations = [NSArray arrayWithObjects:animation1, animation2, nil];
[myView.layer addAnimation:group forKey:@"move-rotate-layer"];

 

CABasicAnimation 动画组合

原文:http://www.cnblogs.com/417460188dy/p/4470513.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!