1     CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
2     transformAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
3     transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(DEGREES_TO_RADIANS(85), 0, 1, 1)]; //  基于Y轴和Z轴同时旋转
4     transformAnimation.duration = 1.5;
5     transformAnimation.autoreverses = YES;
6     transformAnimation.repeatCount = HUGE_VALF;
7     transformAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

 

 1     int tx = 0;
 2     for (CALayer *layer in [rootLayer sublayers]) { // 循环每个子层
 3         [layer addAnimation:transformAnimation forKey:nil];  // 每个子层都加入Y轴和Z轴旋转
 4         
 5         CABasicAnimation *translateAnimation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
 6         translateAnimation.fromValue = [NSValue valueWithCATransform3D:layer.transform];
 7         translateAnimation.toValue = [NSNumber numberWithFloat:tx];
 8         translateAnimation.duration = 1.5;
 9         translateAnimation.autoreverses = YES;
10         translateAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
11         translateAnimation.repeatCount = HUGE_VALF;
12         [layer addAnimation:translateAnimation forKey:nil];
13         tx += 35;
14     }

 

相关文章:

  • 2021-10-26
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
  • 2022-02-09
  • 2021-10-02
  • 2021-04-09
猜你喜欢
  • 2022-12-23
  • 2021-08-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
相关资源
相似解决方案