I have trouble with deleting all of layer\'s sublayers. I currently do this manually, but that brings unnecessary clutter. I found many topics about this in google, but no a
Both setting self.view.layer.sublayers = nil and [layer removeFromSuperlayer] will result in crash if UIView contains any subview. Best way to remove CALayer from superLayer is by maintaining an array of layers.
For instance that array is arrayOfLayers,
Everytime you add a layer on UIView.sublayer add that layer in this array...
For example
[arrayOfLayers addObject:layer];
[self.view.layer addSublayer:layer];
While removing just call this,
[arrayOfLayers makeObjectsPerformSelector:@selector(removeFromSuperlayer)];