WWCaptchaView

main

CAPTCHA - Completely Automated Public Turing test to tell Computers and Humans Apart
William-Weng/WWCaptchaView

WWCaptchaView

Swift-5.6 iOS-14.0 Swift Package Manager-SUCCESS LICENSE

Example.png

Example.gif

dependencies: [
    .package(url: "https://github.com/William-Weng/WWCaptchaView.git", .upToNextMajor(from: "1.0.2"))
]
函式 功能
configure(delegate:stringModel:lineModel) 設定初始值
redrawCaptcha() 重新繪製驗證碼
redrawCaptchaString(_:) 重新繪製自訂驗證碼

Example

import UIKit
import WWPrint
import WWCaptchaView

// MARK: - ViewController
final class ViewController: UIViewController {
    
    @IBOutlet weak var captchaLabel: UILabel!
    @IBOutlet weak var captchaView: WWCaptchaView!
    
    private let stringModel: WWCaptchaView.RandomStringModel = .init(
        digits: "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890甲乙丙丁戊己庚辛壬癸",
        length: 3,
        font: .systemFont(ofSize: 56),
        upperBound: 10,
        color: .black
    )
    
    private let lineModel: WWCaptchaView.RandomLineModel = .init(
        count: 5,
        width: 1.0
    )
    
    override func viewDidLoad() {
        super.viewDidLoad()
        captchaView.configure(delegate: self, stringModel: stringModel, lineModel: lineModel)
    }
}

// MARK: - WWCaptchaViewDelegate
extension ViewController: WWCaptchaViewDelegate {
    func captcha(view: WWCaptchaView, string: String?) { captchaLabel.text = string }
}

Description

  • Swift Tools 5.6.0
View More Packages from this Author

Dependencies

  • None
Last updated: Mon Oct 21 2024 04:46:27 GMT-0900 (Hawaii-Aleutian Daylight Time)