remove all subLayers from a view

前端 未结 9 917
春和景丽
春和景丽 2021-02-01 01:16

In an animation I added a lot of sublayers to a view, with:

[self.view.layer addSublayer:layer1];
[self.view.layer addSublayer:         


        
9条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-01 01:49

    For swift5 to remove CAShapeLayer from added view

    for layer in self.view.layer.sublayers! {
       if layer.isKind(of: CAShapeLayer.self) {
          layer.removeFromSuperlayer()
       }
    }
    

提交回复
热议问题