美文网首页
CAReplicatorLayer

CAReplicatorLayer

作者: 怪客半 | 来源:发表于2016-12-28 14:43 被阅读19次

    原文的代码有点乱,http://www.jianshu.com/p/033c42ea7257
    xib创建view,尺寸约束在右边:

    xib.png
    viewDidLoad中实现代码:
    CAReplicatorLayer *replicator = [CAReplicatorLayer layer];
        replicator.frame = _rilicationView.bounds;
        [_rilicationView.layer addSublayer:replicator];
    
        replicator.instanceCount = 10;
        CATransform3D transform = CATransform3DIdentity;
    //    transform = CATransform3DTranslate(transform, 0, 200, 0);
        transform = CATransform3DRotate(transform, M_PI/5, 0, 0, 1);
    //    transform = CATransform3DTranslate(transform, 0, -200, 0);
        replicator.instanceTransform = transform;
        
        replicator.instanceBlueOffset = -0.1;
        replicator.instanceGreenOffset = -0.1;
        
        CALayer *layer = [CALayer layer];
        layer.frame = CGRectMake(0, 0, 50, 50);
        layer.backgroundColor = [UIColor whiteColor].CGColor;
        [replicator addSublayer:layer];
    

    运行效果:

    效果.png

    蓝色view的尺寸是推算出来的。。

    计算过程.JPG

    相关文章

      网友评论

          本文标题:CAReplicatorLayer

          本文链接:https://www.haomeiwen.com/subject/ovuyvttx.html