CAReplicatorLayer

2016-12-28  本文已影响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
上一篇下一篇

猜你喜欢

热点阅读