In an animation I added a lot of sublayers to a view, with:
[self.view.layer addSublayer:layer1];
[self.view.layer addSublayer:layer2];
....
I would like to remove all sublayers with an action. I already tried with this suggestion of a similar question:
rootLayer.sublayers = nil;
but it doesn't work...
Could you help me? Than you!
sublayers
to an array prepopulated withCALayer
objects. My solution is still correct, though. Also this oneliner should probably work (untested):[self.view.layer.sublayers makeObjectsPerformSelector:@selector(removeFromSuperlayer)]
– Heartsease