iOS Element Types
TextElementUITextField
The TextElementUITextField
element type enables collecting user String data. Mask and transform capabilities are available to be configured on these elements.
import Foundation
import UIKit
import BasisTheoryElements
import Combine
class TokenizeName: UIViewController {
@IBOutlet weak var nameTextField: TextElementUITextField!
@IBOutlet weak var output: UITextView!
@IBAction func tokenize(_ sender: Any) {
let body: [String: Any] = [
"data": [
"name": self.nameTextField,
],
"type": "token"
]
BasisTheoryElements.tokenize(body: body, apiKey: config.btApiKey!) { data, error in
guard error == nil else {
self.output.text = "There was an error!"
print(error)
return
}
let stringifiedData = String(data: try! JSONSerialization.data(withJSONObject: data!.value as! [String: Any], options: .prettyPrinted), encoding: .utf8)!
self.output.text = stringifiedData
print(stringifiedData)
}
}
}
Configuration
The TextElementUITextField
extends the native UITextField
from UIKit, so all standard properties and methods supported by UITextField are supported by TextElementUITextField
.
Properties
The following additional properties are supported when programmatically interacting with a TextElementUITextField
:
Name | Type |
---|---|
validation | No default validation. Validation can be overridden. |
mask | No default mask. Mask can be overridden. |
transform | No default transform. Transform can be overridden. |
enableCopy | enableCopy defaults to false and can be overriden. |
copyIconColor | copyIconColor defaults to UIColor.blue and can be overriden. |
getValueType | getValueType defaults to .string and can be overriden. |
TextElementUITextField
extends the native iOS UITextField from UIKit, so all standard properties and attributes supported by UITextField are supported by TextElementUITextField
.