DSCurrencyInputMask

public class DSCurrencyInputMask : DSInputMask

The DSCurrencyInputMask, 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)
  • Numbers and the decimal point are needed to enter a currency.

    Declaration

    Swift

    public var keyboardType: UIKeyboardType? { get }