Skip to content

TKCurrencyTextField is a UITextField component that makes the currency string mask of the current or fixed locale.

License

Notifications You must be signed in to change notification settings

Wagnesio/TKCurrencyTextField

 
 

Repository files navigation

TKCurrencyTextField

CI Status Carthage compatible

TKCurrencyTextField is a UITextField component that makes the currency string mask of the current or fixed locale.

Example

To run the example project, clone the repo and open TKCurrencyTextField.xcodeproj

Requirements

  • Swift 3
  • Deployment target 8.0

Installation

Carthage

Simply add the following lines to your Cartfile:

github 'tokenlab/TKCurrencyTextField', '~> 1.0'

CocoaPods

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'

How to use

TKCurrencyTextField can be used simply setting custom class to UITextField:

Customization

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
}

Functions

To manually set an amount, use this function:

currencyTextField.setAmount(123.45)

To get textField amount as Double:

let currency = currencytTextField.getAmount

Default values

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

Authors

Daniele Boscolo, danieleboscolo@tokenlab.com.br

Wagner Silva, wagnersilva@tokenlab.com.br

Edson Bueno, edsonbueno@tokenlab.com.br

License

TKCurrencyTextField is available under the MIT license. See the LICENSE file for more info.

About

TKCurrencyTextField is a UITextField component that makes the currency string mask of the current or fixed locale.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 93.5%
  • Ruby 3.3%
  • Objective-C 3.2%