Class
DSCurrencyInputMask
public class DSCurrencyInputMask: DSInputMask
An input mask, when assigned to a DSTextField, will enforce use of a decimal pad for text entry and only allows digits and a decimal point (no more than one) to be entered.
It's recommended to use prefix text for currency entry which will display in the field.
let textField = DSTextField()
textField.inputMask = DSCurrencyInputMask()
textField.prefixText = Locale.current.currencySymbol ?? "$"
let currencyText = textField.text // <-- $1.23 (as seen)
let currency = textField.rawText // <-- 1.23 (without formatting)
Relationships
Conforms To
DSInputMask
A masking object that controls what can be legally typed into a DSTextField and handles type formatting while that typing takes place. They do not validate but often "partner" up with validation rules.
Initializers
init()
public init()
Properties
keyboardType
public var keyboardType: UIKeyboardType?
Numbers and the decimal point are needed to enter a currency.
Methods
rawText(from:)
public func rawText(from text: String) -> String
Raw numeric text and the decimal separator.
shouldAllow(replacementString:resultingString:)
public func shouldAllow(replacementString string: String, resultingString: String) -> Bool
Only allow numeric digits and one single decimal separator.
applyFormattingMask(to:)
public func applyFormattingMask(to text: String) -> String