From a5ae9304b7d295cc7875573669895b2c15d4f48a Mon Sep 17 00:00:00 2001 From: Joseph Date: Tue, 23 Nov 2021 21:57:25 -0700 Subject: [PATCH] Corrected use of sublayers --- Cosmos/CosmosView.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 // ------------