extension Binding where Value == Int {
public func float() -> Binding<Float> {
return Binding<Float>(get:{ Float(self.wrappedValue) },
set: { self.wrappedValue = Int($0)})
}
}
...
// self.$data.count is Binding<Int>
Slider(value: self.$data.count.float(), in:1...16) {
Text("Number")
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17