CABasicAnimation 动画组合

使用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"];

 

转载于:https://www.cnblogs.com/417460188dy/p/4470513.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值