Contents

william-weng/wwonetimepasswordview

- [Simple one-time password input text field.](https://medium.com/@dejanvu.developer/email-verification-with-sent-codes-in-ruby-on-rails-a-step-by-step-guide-039bcf194634)

[Introduction - 簡介](https://swiftpackageindex.com/William-Weng)

[WWOneTimePasswordView]

[IBDesignable]

[Installation with Swift Package Manager](https://medium.com/彼得潘的-swift-ios-app-開發問題解答集/使用-spm-安裝第三方套件-xcode-11-新功能-2c4ffcf85b4b)

dependencies: [
    .package(url: "https://github.com/William-Weng/WWOneTimePasswordView.git", .upToNextMajor(from: "1.2.0"))
]

可用函式

|函式|說明| |-|-| |initSetting(count:appearanceType:keyboardType:spacing:codeLabelFont:textColor:codeLabelBackgroundColor:generalBorderParameter:selectedBorderParameter:)|初始化設定| |reset()|重置畫面|

WWOneTimePasswordViewDelegate

|函式|說明| |-|-| |oneTimePasswordView(_:status:password:replacementString:)|取得輸入的密碼|

Example

import UIKit
import WWOneTimePasswordView

@IBDesignable
final class MyOneTimePasswordView: WWOneTimePasswordView {}

final class ViewController: UIViewController {
    
    @IBOutlet weak var password1View: MyOneTimePasswordView!
    @IBOutlet weak var password2View: MyOneTimePasswordView!

    override func viewDidLoad() {
        super.viewDidLoad()
        
        password1View.initSetting(count: 6, appearanceType: .border)
        password1View.delegate = self
        
        password2View.initSetting(count: 4, appearanceType: .underLine, codeLabelFont: .systemFont(ofSize: 56.0), codeLabelBackgroundColor: .clear)
        password2View.delegate = self
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
        view.endEditing(true)
    }
    
    @IBAction func resetCode1View(_ sender: UIBarButtonItem) {
        password1View.reset()
    }
    
    @IBAction func resetCode2View(_ sender: UIBarButtonItem) {
        password2View.reset()
    }
}

extension ViewController: WWOneTimePasswordViewDelegate {
    
    func oneTimePasswordView(_ oneTimePasswordView: WWOneTimePasswordView, status: WWOneTimePasswordView.Status, password: String, replacementString: String?) {
        print("\(oneTimePasswordView.tag) => \(status) => \(password) => \(replacementString ?? "<nil>")")
    }
}

Package Metadata

Repository: william-weng/wwonetimepasswordview

Default branch: main

README: README.md