原文的代码有点乱,http://www.jianshu.com/p/033c42ea7257
xib创建view,尺寸约束在右边:
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
网友评论