• ReplicatorLayer 复制图层


    使用文档介绍:

    #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(0, 0, 10, 10);
        sharLayer.position = CGPointMake(kWidth/2, 150);
        sharLayer.cornerRadius = 5;
        
        //    CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
        //    scaleAnimation.toValue = @10;
        CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
        scaleAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(10, 10, 1)];
        scaleAnimation.duration = 2;
        
        CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
        opacityAnimation.fromValue = @1;
        opacityAnimation.toValue = @0;
        opacityAnimation.duration = 2;
        
        CAAnimationGroup *group = [CAAnimationGroup animation];
        group.animations = @[scaleAnimation,opacityAnimation];
        group.duration = 2;
        group.repeatCount = HUGE;
        
        [sharLayer addAnimation:group forKey:nil];
        
        
        CAReplicatorLayer *replayer = [CAReplicatorLayer layer];
        replayer.instanceDelay = 0.5;
        replayer.instanceCount = 3;
        [replayer addSublayer:sharLayer];
        
        [self.view.layer addSublayer:replayer];
        
        
    }

    参考:

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

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

  • 相关阅读:
    Jmeter非GUI模式运行脚本
    vmware下 linux如何扩展磁盘空间
    (完美解决方案)Windows Server 2012 R2报错:无法启动此程序,因为计算机中丢失 apimswincrtstdiol110.dll 解决
    Python程序执行性能优化心得
    jmeter中TPS和吞吐量区别与联系
    Python多进程之Pool进程池浅析
    为什么Jmeter 运行时到达持续时间不停止?
    一些在线实用小工具
    笔记20171225
    JMeter 安装 linux平台
  • 原文地址:https://www.cnblogs.com/daxueshan/p/11169694.html
Copyright © 2020-2023  润新知