In an animation I added a lot of sublayers to a view, with:
[self.view.layer addSublayer:layer1];
[self.view.layer addSublayer:
If you want to delete all sublayers and add a new one, you can easily do:
rootLayer.sublayers = [layer1] // adding one layer
rootLayer.sublayers = [layer1, layer2, ...] // adding two or more layers
This could be helpful, if you work with tableview
or collectionview cells
. You don't need to call prepareForReuse
for removing the sublayers
.