Issue #921
Use HStack
with TextField
and a little extension
extension Binding where Value == Int {
var toString: Binding<String> {
Binding<String>(
get: {
"\(wrappedValue)"
},
set: {
wrappedValue = Int($0) ?? 0
}
)
}
}
struct TextFieldStepper: View {
@Binding var value: Int
var body: some View {
HStack(spacing: 0) {
TextField("", text: $value.toString)
.textFieldStyle(.roundedBorder)
.frame(width: 50)
Stepper("", value: $value)
}
}
}