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
You could simply provide an identifier for the CAlayer you have added and remove it by searching for it. Like so
let spinLayer = CAShapeLayer()
spinLayer.path = UIBezierPath()
spinLayer.name = "spinLayer"
func removeAnimation() {
for layer in progressView.layer.sublayers ?? [CALayer]()
where layer.name == "spinLayer" {
layer.removeFromSuperlayer()
}
}