使用文档介绍:

#import <QuartzCore/CALayer.h>

NS_ASSUME_NONNULL_BEGIN
CA_CLASS_AVAILABLE (10.6, 3.0, 9.0, 2.0)
@interface CAReplicatorLayer : CALayer //指定图层重复制多少次
@property NSInteger instanceCount; //设置为YES,图层将保持于CATransformLayer类似的性质和相同的限制
@property BOOL preservesDepth; //复制延时,一般用在动画上
@property CFTimeInterval instanceDelay; //3D变换
@property CATransform3D instanceTransform; //设置多个复制图层的颜色,默认位白色
@property(nullable) CGColorRef instanceColor; //设置每个复制图层相对上一个复制图层的红色、绿色、蓝色、透明度偏移量
@property float instanceRedOffset;
@property float instanceGreenOffset;
@property float instanceBlueOffset;
@property float instanceAlphaOffset; @end NS_ASSUME_NONNULL_END

例: 渐变动画

- (void)scaleAndOpcatityAnim{
CAShapeLayer *sharLayer = [CAShapeLayer layer];
sharLayer.backgroundColor = [UIColor redColor].CGColor;
sharLayer.bounds = CGRectMake(, , , );
sharLayer.position = CGPointMake(kWidth/, );
sharLayer.cornerRadius = ; // CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
// scaleAnimation.toValue = @10;
CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
scaleAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(, , )];
scaleAnimation.duration = ; CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
opacityAnimation.fromValue = @;
opacityAnimation.toValue = @;
opacityAnimation.duration = ; CAAnimationGroup *group = [CAAnimationGroup animation];
group.animations = @[scaleAnimation,opacityAnimation];
group.duration = ;
group.repeatCount = HUGE; [sharLayer addAnimation:group forKey:nil]; CAReplicatorLayer *replayer = [CAReplicatorLayer layer];
replayer.instanceDelay = 0.5;
replayer.instanceCount = ;
[replayer addSublayer:sharLayer]; [self.view.layer addSublayer:replayer]; }

参考:

https://www.cnblogs.com/xianfeng-zhang/p/7759919.html

https://www.jianshu.com/p/2e6facd8142f

最新文章

  1. 由外边距合并到BFC
  2. hdu1171
  3. Linux 下安装python软件包(pip、nose、virtualenv、distribute )
  4. C#中的事件-订阅与发布
  5. bzoj2946 [Poi2000]公共串(SA,SAM)
  6. WPF自定义窗体仿新毒霸关闭特效(只能在自定义窗体中正常使用)
  7. AOP Aspect Oriented Programming
  8. MS SQL优化
  9. Android回调详解
  10. PHP 进行支付宝开发中return_url和notify_url的区别分析
  11. AES和RSA算法的demo代码
  12. 学习人工智还死拽着Python不放?大牛都在用Anaconda5.2.0
  13. CSS 浮动和清除
  14. hadoop之 node manager起不来, 执行mapreduce 程序hang住
  15. 附3 springboot源码解析 - 构建SpringApplication
  16. Java之父及Java诞生
  17. JAVA WEB 前台实时监控后台程序运行
  18. 二、Django快速安装
  19. slf4j log4j logback log4j2关系详解和相关用法
  20. Spring Boot CRUD+分页(基于Mybatis注解方式)

热门文章

  1. C++学习笔记(三)--数组、字符串
  2. HTML批量修改——正则表达式实践
  3. POJ-1287.Network(Kruskal + Prim + Prim堆优化)
  4. Spacemacs 的配置
  5. vector中数据释放崩溃问题
  6. k3 cloud套打模板中出现单元格数据为空的情况,及无法正确的选择数据源
  7. PHP算法[转]
  8. windows安装 阿里云的Fun工具
  9. @RestController vs @Controller
  10. ELKStack之操作深入(中)