blob: f61641305cfbdf099130842afa40555225ed0e10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import SwiftUI
struct DecimalTextField: View {
@Binding var value: CGFloat
private let decimalFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
formatter.allowsFloats = true
formatter.minimumFractionDigits = 1
formatter.decimalSeparator = "."
return formatter
}()
var body: some View {
TextField("maxMagnification", value: $value, formatter: decimalFormatter)
.textFieldStyle(RoundedBorderTextFieldStyle())
.multilineTextAlignment(.trailing)
.keyboardType(.decimalPad)
}
}
|