-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sliders.swift
41 lines (33 loc) · 935 Bytes
/
Sliders.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import SwiftUI
struct Sliders: View {
@State var value: Double = 0.10
@State var rangeValue: Double = 3
@State var color: Color = .red
var body: some View {
VStack {
Text("Rating")
Text(String(format: "%.1f", value))
Slider(value: $value)
.tint(.red)
Text("Rating \(rangeValue)")
.foregroundStyle(color)
Slider(
value: $rangeValue,
in: 1...5,
step: 1.0,
onEditingChanged: { _ in
color = .green
},
minimumValueLabel: Text("1"),
maximumValueLabel: Text("5"),
label: {
Text("Rating")
}
)
}
.padding(50)
}
}
#Preview {
Sliders()
}