假设一个 CALayer 会生成一些子 layers ,重置的时候,各位是用removeFromSuperlayer
,还是直接sublayers = []
?
class Mycalayer: CALayer {
func update () {
// insert some Sublayers here
.....
}
func refresh () {
// reset all sublayers
self.sublayers?.forEach { layer in
layer.removeFromSuperlayer()
}
// OR Just
self.sublayers = []
}
}