diff --git a/Cosmos/CosmosView.swift b/Cosmos/CosmosView.swift index 80c6fad..eb134a8 100644 --- a/Cosmos/CosmosView.swift +++ b/Cosmos/CosmosView.swift @@ -101,6 +101,7 @@ Shows: ★★★★☆ (123) Updates the stars and optional text based on current values of `rating` and `text` properties. */ + private var previousLayers: Array = [] open func update() { // Create star layers @@ -120,8 +121,9 @@ Shows: ★★★★☆ (123) layers = addTextLayer(textLayer: textLayer, layers: layers) } - layer.sublayers = layers - + for l in previousLayers { l.removeFromSuperlayer() } + for l in layers { layer.addSublayer(l) } + previousLayers = layers // Update size // ------------