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