Latest 0.1.0
Homepage https://github.com/LiuSky/CodeTextField
License MIT
Platforms ios 9.0, requires ARC
Authors

Requirements:

  • iOS 9.0+
  • Xcode 10.1+
  • Swift 5.0

Installation Cocoapods

pod 'CodeTextField', '~> 0.1.0'

Demo Figure

Usage

1. 样式1

    private lazy var style1: CodeTextField = {

        let temTextField = CodeTextField(codeLength: 4,
                                         characterSpacing: 10,
                                         validCharacterSet: CharacterSet(charactersIn: "0123456789"),
                                         characterLabelGenerator: { (_) -> LableRenderable in
                                           return StyleLabel(size: CGSize(width: 50, height: 50))
        })
        temTextField.keyboardType = .numberPad
        return temTextField
    }()

2.样式4

    /// 样式4
    private lazy var style4: CodeTextField = {

        let temTextField = CodeTextField(codeLength: 6,
                                         characterSpacing: 10,
                                         validCharacterSet: CharacterSet(charactersIn: "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"),
                                         characterLabelGenerator: { (idx) -> LableRenderable in

                                            switch idx {
                                            case 0:
                                                return StyleLabel(size: CGSize(width: 50, height: 50))
                                            case 1:
                                                let label = StyleLabel(size: CGSize(width: 50, height: 50))
                                                label.style = Style.border(nomal: UIColor.gray, selected: UIColor.blue)
                                                return label
                                            case 2:
                                                return StyleLabel(size: CGSize(width: 50, height: 50))
                                            case 3:
                                                let label = StyleLabel(size: CGSize(width: 50, height: 50))
                                                label.style = Style.border(nomal: UIColor.gray, selected: UIColor.orange)
                                                return label
                                            case 4:
                                                return StyleLabel(size: CGSize(width: 50, height: 50))
                                            default:
                                                let label = StyleLabel(size: CGSize(width: 50, height: 50))
                                                label.style = Style.border(nomal: UIColor.gray, selected: UIColor.purple)
                                                return label
                                            }
        })
        temTextField.keyboardType = .asciiCapable
        temTextField.autocorrectionType = .no
        return temTextField
    }()

Reference

License

CodeTextField is released under an MIT license. See LICENSE for more information.

Latest podspec

{
    "name": "CodeTextField",
    "version": "0.1.0",
    "summary": "u9a8cu8bc1u7801u6587u672cu7ec4u4ef6",
    "description": "u9a8cu8bc1u7801u6587u672cu7ec4u4ef6",
    "homepage": "https://github.com/LiuSky/CodeTextField",
    "license": "MIT",
    "authors": {
        "xiaobin liu": "[email protected]"
    },
    "source": {
        "git": "https://github.com/LiuSky/CodeTextField.git",
        "tag": "0.1.0"
    },
    "swift_versions": "5.0",
    "requires_arc": true,
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "CodeTextField/Core/*.swift"
}

Pin It on Pinterest

Share This