Latest 1.0.0
Homepage https://github.com/shima11/PinCodeInputView
License MIT
Platforms ios 10.0
Authors

A text input view for entering pin code.

Features

  • something…

Getting Started

View Hierarchy

SurfaceView is used to detect a user gesture.
ItemView is Appearance. You can customize ItemView.

private class ContainerItemView<T: UIView & ItemType>: UIView {
    var itemView: T
    private let surfaceView: UIView = .init()
    private var didTapHandler: (() -> ())?
}

To create your customize ItemView, you create a view conforming to ItemType.

public protocol ItemType {
    var text: Character? { get set }
    var isHiddenCursor: Bool { get set }
    func set(appearance: Appearance)
}

About to set appearance.

public struct Appearance { }

pinCodeInputView.set(appearance: )

Usage

import PinCodeInputView

standard


// initialize
let pinCodeInputView: PinCodeInputView<ItemView> = .init(
    digit: 6,
    itemSpacing: 8,
    itemFactory: {
    return ItemView()
})

view.addSubview(pinCodeInputView)

// set appearance
pinCodeInputView.set(
    appearance: .init(
        itemSize: .init(width: 44, height: 68),
        font: .systemFont(ofSize: 28, weight: .bold),
        textColor: .white,
        backgroundColor: .darkGray,
        cursorColor: .blue,
        cornerRadius: 8
    )
)

// text handling
pinCodeInputView.set(changeTextHandler: { text in
    print(text)
})

customize

final class CustomItemView: UIView, ItemType {
    var text: Character?
    var isHiddenCursor: Bool
    func set(appearance: Appearance) {}

    // ...
}

let pinCodeInputView: PinCodeInputView<CustomItemView> = .init(
    digit: 6,
    itemSpacing: 8,
    itemFactory: {
    return CustomItemView()
})

Installation

Carthage

For Installing with Carthage, and add it to your Cartfile.

github "shima11/PinCodeInputView"
$ carthage update

CocoaPods

For installing with CocoaPods, and add it to your Podfile.

pod "PinCodeInputView"
$ pod update

License

Licence MIT

Latest podspec

{
    "name": "PinCodeInputView",
    "version": "1.0.0",
    "summary": "TextView for entering pin code.",
    "description": "TextView for entering pin code. nYou can create an input part of PinCode to use for phone number authentication.",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "homepage": "https://github.com/shima11/PinCodeInputView",
    "authors": {
        "shima": "[email protected]"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source": {
        "git": "https://github.com/shima11/PinCodeInputView.git",
        "tag": "1.0.0"
    },
    "source_files": [
        "PinCodeInputView",
        "PinCodeInputView/**/*.{h,m,swift}"
    ]
}

Pin It on Pinterest

Share This