GithubHelp home page GithubHelp logo

0del / pincodeinputview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shima11/pincodeinputview

0.0 0.0 0.0 2.88 MB

A input text view for entering pin code.

License: MIT License

Swift 88.34% Ruby 7.66% Objective-C 4.00%

pincodeinputview's Introduction

PinCodeInputView

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

pincodeinputview's People

Contributors

shima11 avatar jrosen081 avatar 9bany avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.