Hi All,
I have a slider,
I would like to use this slider for the scale:
Terrible,
Very poor,
Poor,
Average ......etc
The slider gives me the values 1-7 how can I turn these into a string to show on the screen?
Thanks all
I have a slider,
Code Block @State private var appearance: Double = 4 Slider(value: $appearance, in: 1...7, step: 1)
I would like to use this slider for the scale:
Terrible,
Very poor,
Poor,
Average ......etc
The slider gives me the values 1-7 how can I turn these into a string to show on the screen?
Thanks all
Something like this?
You may want to consider internationalization, but that is another issue...
Code Block struct ContentView: View { @State private var appearance: Float = 4 let appearanceText = [ "Terrible", "Very poor", "Poor", "Average", "...", "...", "..." ] var body: some View { VStack { Text("appearance: \(appearanceText[Int(appearance)-1])") Slider(value: $appearance, in: 1...7, step: 1) } } }
You may want to consider internationalization, but that is another issue...