/AuthField

AuthField is customizable pin code field like apple 2-factor authentication (自作Libraryの練習1)

Primary LanguageSwiftMIT LicenseMIT

AuthField

AuthField is customizable pin code field like apple 2-factor authentication

gif

Usage

let authField = AuthField(pinCount: 6)
view.addSubview(authField)

Customization

let authFieldConfiguration = AuthFieldConfiguration(
    pinCount: 6,
    font: .boldSystemFont(ofSize: 25),
    spacing: 12,
    boxWidth: 42,
    boxHeight: 52,
    borderColor: .lightGray,
    selectedBorderColor: .systemGreen,
    borderWidth: 1,
    selectedBorderWidth: 2,
    boxCornerRadius: 12,
    boxBackgroundColor: .white
)
let authField = AuthField(configuration: authFieldConfiguration)
view.addSubview(authField) 

properties

authField.pin = 123456 // default pin code
authField.isSpaceInTheMiddleEnabled = true // Put a space in the middle of the boxes.

Delegation

authField.delegate = self

Called when all pin codes have been entered

extension ViewController : AuthFieldDelegate {
    func endEditing(_ authField: AuthField, pinCode: Int) {
        print(pinCode)
    }
}