From 5e4554272f1262120a643efb39ccdb890ae592fe Mon Sep 17 00:00:00 2001 From: benedom <> Date: Tue, 16 Apr 2024 10:51:16 +0200 Subject: Adjusted demo application to include all configuration options --- .../SwiftyCropDemo/UIElements/DecimalTextField.swift | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Demo/SwiftyCropDemo/UIElements/DecimalTextField.swift (limited to 'Demo/SwiftyCropDemo/UIElements/DecimalTextField.swift') diff --git a/Demo/SwiftyCropDemo/UIElements/DecimalTextField.swift b/Demo/SwiftyCropDemo/UIElements/DecimalTextField.swift new file mode 100644 index 0000000..f616413 --- /dev/null +++ b/Demo/SwiftyCropDemo/UIElements/DecimalTextField.swift @@ -0,0 +1,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) + } +} -- cgit v1.2.3