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
For swift3+,You can use this.
yourView.layer.sublayers?.removeAll(keepingCapacity: true)
See here: Apple API Reference
Or you can: yourView.layer.sublayers?.forEach{ $0.removeFromSuperlayer()}
yourView.layer.sublayers?.forEach{ $0.removeFromSuperlayer()}