blob: 9758f0f860978b8119da0421dafb3ff37f4b168b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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)
#if canImport(UIKit)
.keyboardType(.decimalPad)
#endif
}
}
|