1、CAReplicatorLayer简介

  CAReplicatorLayer用于对图层进行复制,包括图层的动画也能复制!可以看着将某一段事务进行重复!

#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

2、CAReplicatorLayer的简单使用

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

效果图

- (void)alphaAction{
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.backgroundColor = [UIColor redColor].CGColor;
shapeLayer.bounds = CGRectMake(, , , );
shapeLayer.position = CGPointMake(CScreenWidth/, );
shapeLayer.borderColor = [UIColor whiteColor].CGColor;
shapeLayer.cornerRadius = ;
shapeLayer.borderWidth = ;
shapeLayer.transform = CATransform3DMakeScale(., ., .); CABasicAnimation *ani = [CABasicAnimation animationWithKeyPath:@"transform"];
ani.duration = ;
ani.repeatCount = HUGE;
ani.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(, , )];
ani.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(., ., .)];
[shapeLayer addAnimation:ani forKey:nil]; CAReplicatorLayer *repLayer = [CAReplicatorLayer layer];
repLayer.frame = CGRectMake(, , CScreenWidth, ); [repLayer addSublayer:shapeLayer];
repLayer.instanceCount = ;
repLayer.instanceDelay = .;
repLayer.instanceTransform = CATransform3DMakeRotation(M_PI/, , , );
repLayer.instanceAlphaOffset = -0.05;
[self.showView.layer addSublayer:repLayer]; }

效果图

最新文章

  1. 两个不同的list随机组合到一个List中。
  2. C#如何关闭一个窗口的同时打开另一个窗口
  3. 团体程序设计天梯赛-练习集L2-004. 这是二叉搜索树吗
  4. SD卡中FAT32文件格式快速入门(图文详细介绍)
  5. 【POJ2912】【并查集】Rochambeau
  6. ubuntu 下修改host文件
  7. ios创建画笔的样例(双笔画效果)
  8. 微通道产品经理Grover采访:美国的微通道设计
  9. C#实现的HttpGet请求
  10. [Swift]LeetCode291. 单词模式 II $ Word Pattern II
  11. MySQL8.0关于caching_sha2_password Plugin的一个Bug
  12. log4写完日志不会自动释放
  13. 在mysql存储过程中拼接sql解决in的字段类型不匹配问题
  14. 在本机搭建mycat 单机环境,使用mariadb 伪集群
  15. [py]py常用模块小结
  16. 学习总结---INNODB 事务并发
  17. Docker容器打包成镜像 - OpenDaylight官方 SDN Hub Tutorial VM 的docker镜像
  18. [ZJOI2019]语言[树链的并、线段树合并]
  19. AOP:声明式事务管理流程
  20. Arcgis Android 手动搭建开发环境

热门文章

  1. 彻底搞定C指针-函数名与函数指针
  2. 杂项-Tmod:常见错误提示
  3. python自带的split VS numpy中的split比较
  4. 如何获得一个干净的 gnome 开发环境?
  5. JS原型与原型链终极详解 (转载)
  6. C++中类的静态成员变量
  7. 新手学习 React 迷惑的点
  8. java中延迟任务的处理方式
  9. 从OLLVM4.0.0升级到LLVM8.0.1,并且给LLVM增加Pass 插件系统
  10. ORM:Chloe