CAReplicatorLayer

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

CAReplicatorLayer_第1张图片
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];

运行效果:

CAReplicatorLayer_第2张图片
效果.png

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

计算过程.JPG

你可能感兴趣的:(CAReplicatorLayer)