Search code examples
iosobjective-ccore-graphicscore-animation

iOS - copy a CALayer in ViewdidLoad


I got a CALayer and I want to copy it into 5 or more CALayers in ViewdidLoad is there is a possible way to do this. Here is my layer:

alye = [CALayer layer];
alye.position = CGPointMake(129, 189);
alye.bounds = CGRectMake(0, 0, theHeight/13.45, theWidth/2.66);
alye.backgroundColor = [UIColor redColor].CGColor;
alye.opacity = 0.6f;
[self.view.layer addSubLayer:alye];

Any help please?
Thanks in advance


Solution

  • If you want to create multiple duplicates of a layer, take a look at a CAReplicatorLayer. That lets you create multiple copies of a source layer, applying a transform to each copy.