/

UI Components

VGSTextField

An object that displays an editable text area in your interface.

Declaration

class VGSTextField: UIView
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

VGSTextField UI attributes

VGSTextField have similar attributes to native iOS UITextField attributes. To check full list of available attributes check VGSCollectSDK Reference Docs

VGSTextField Functional attributes

The VGSTextField class provide built-in support for input text validation and formatting. Each VGSTextField should be configured with VGSConfiguration object.

AttributeDescription
configurationVGSConfiguration instance, specifies textfield required configuration
delegateVGSTextFieldDelegate object that will handle text field editing process
stateread-only State instance, represent textfield's current parameters as isValid, isEmpty, etc.

To use all the power of VGSTextField you can track VGSTextField.state object and implement VGSTextFieldDelegate methods.

VGSTextFieldDelegate

VGSTextFieldDelegate include functionality similar to native UITextFieldDelegate.

Declaration

protocol VGSTextFieldDelegate
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

Managing VGSTextField Editing process

/// VGSTextField did become first responder
optional func vgsTextFieldDidBeginEditing(_ textfield: VGSTextField)

/// VGSTextField's input changed
optional func vgsTextFieldDidChange(_ textField: VGSTextField)

/// VGSTextField did resign first responder
optional func vgsTextFieldDidEndEditing(_ textfield: VGSTextField)

/// VGSTextField did resign first responder on Return button pressed
optional func vgsTextFieldDidEndEditingOnReturn(_ textfield: VGSTextField)
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

Code example

class ViewController {

  var expCardDateField = VGSTextField()
  var cardNumberField = VGSCardTextField()

  // ...

  /// Set VGSTextFieldDelegate to handle editing events
  expCardDateField.delegate = self
  cardNumberField.delegate = self

  // ...
}

/// Handle VGSTextFieldDelegate methods
extension ViewController: VGSTextFieldDelegate {

  /// VGSTextField did start editing.
  func vgsTextFieldDidBeginEditing(_ textField: VGSTextField) {
    print("\(textField.state.fieldName) did start editing")
    textField.borderColor = .gray
  }

  /// VGSTextField was edited.
  func vgsTextFieldDidChange(_ textField: VGSTextField) {
     print("\(textField.state.fieldName) did changed. Input characters count: \(textField.state.inputLength)")
  }

  /// VGSTextField did resign first responder.
  func vgsTextFieldDidEndEditing(_ textField: VGSTextField) {
    if !textField.state.isValid {
      textField.borderColor = .red
    }
    print("\(textField.state.fieldName) did end editing with state: \(textField.state.description)")
  }

  /// VGSTextField did resign first responder on Return button pressed.
  func vgsTextFieldDidEndEditingOnReturn(_ textField: VGSTextField) {
    /// Switch to next field programatically
    if textField == cardNumberField {
      expCardDateField.becomeFirstResponder()
    }
  }
}
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

VGSTextField UIResponder methods

/// Returns a Boolean value indicating whether this object is the first responder
var isFirstResponder: Bool

/// Asks UIKit to make this object the first responder
@discardableResult func becomeFirstResponder() -> Bool

/// Asks UIKit to resign this object as first responder
@discardableResult func resignFirstResponder() -> Bool
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

VGSCardTextField

An object that displays an editable text area, for use instead of a VGSTextField when need to detect and show credit card brand images.

Declaration

class VGSCardTextField: VGSTextField
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

Overview

VGSCardTextField inherits same functionality as default VGSTextField. In addition it detects credit card brand while user typing data and displays brand image in a text field. All card brand images are included in the SDK, however you still can set your custom images.

Setting custom card brand images


/// set card brand icon location inside VGSCardTextField
var cardIconLocation: VGSCardTextField.CardIconLocation

/// set card brand icon size inside VGSCardTextField
var cardIconSize: CGSize

/// set image for specific card type
var cardsIconSource: ((SwiftLuhn.CardType) -> UIImage?)?
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

Code example

var cardNumberField = VGSCardTextField()
cardNumberField.cardIconLocation = .left
cardNumberField.cardIconSize = CGSize(width: 45, height: 45)

cardNumberField.cardsIconSource = { cardType in
    switch cardType {
    case .mastercard:
        return UIImage(named: "<custom mastercard icon>")
    case .visa:
        return UIImage(named: "<custom visa icon>")
    default:
        return nil
    }
}
This is a sample VGS echo server
This is a login from access credentials
This is a password from access credentials
This is a HTTP port number to access
This is a  sample VGS alias  in a generic format
This is a sample test  vault id
This is a username/password pair of  access credentials  for a sample test vault
This is a sample  vault url, that contains the vault id and the sandbox environment
This is a sample  vault host,  which contains sample test vault id and sandbox environment
This is a current Organization ID
This is a current vault id
The unique name that identifies a specific iframe
This is a  sample VGS alias  in a generic format

For more details about available attributes and functionality check VGSCollectSDK Reference docs