TKCurrencyTextField is a UITextField component that makes the currency string mask of the current or fixed locale.
To run the example project, clone the repo and open TKCurrencyTextField.xcodeproj
- Swift 3
- Deployment target 8.0
Simply add the following lines to your Cartfile:
github 'tokenlab/TKCurrencyTextField', '~> 1.0'
TKCurrencyTextField is available through Tokenlab's TKPodSpec. To install it, simply add the following lines to your Podfile:
source 'https://github.com/tokenlab/TKPodSpecs'
pod 'TKCurrencyTextField', '~> 1.0'
TKCurrencyTextField can be used simply setting custom class to UITextField:
You may customize by Interface Builder. E.g: Fixed locale to Brazil without currency symbol:
Or code:
@IBOutlet weak var currencyTextField: TKCurrencyTextField!
override func viewDidLoad() {
super.viewDidLoad()
currencyTextField.defaultValue = 100.00
currencyTextField.maxDigits = 8
currencyTextField.currencySymbol = false
currencyTextField.locale = Locale(identifier: "pt_BR") // Brazil
}
To manually set an amount, use this function:
currencyTextField.setAmount(123.45)
To get textField amount as Double:
let currency = currencytTextField.getAmount
Definition | var | type | value |
---|---|---|---|
Initial amount | defaultValue | Double | 0.0 |
Maximum number of digits | maxDigits | Int | 15 |
Show/Hide currency symbol | currencySymbol | Bool | true |
Currency of the country | locale | Locale | Locale.current |
Daniele Boscolo, danieleboscolo@tokenlab.com.br
Wagner Silva, wagnersilva@tokenlab.com.br
Edson Bueno, edsonbueno@tokenlab.com.br
TKCurrencyTextField is available under the MIT license. See the LICENSE file for more info.