https://github.com/shima11/pincodeinputview
A input text view for entering pin code.
https://github.com/shima11/pincodeinputview
caret carthage cocoapods cursor inputview itemview pincode textview uitextfield uitextview
Last synced: 5 months ago
JSON representation
A input text view for entering pin code.
- Host: GitHub
- URL: https://github.com/shima11/pincodeinputview
- Owner: shima11
- License: mit
- Created: 2018-11-05T10:23:19.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-08-31T09:11:34.000Z (about 2 years ago)
- Last Synced: 2025-04-19T22:16:18.120Z (6 months ago)
- Topics: caret, carthage, cocoapods, cursor, inputview, itemview, pincode, textview, uitextfield, uitextview
- Language: Swift
- Homepage:
- Size: 2.81 MB
- Stars: 160
- Watchers: 4
- Forks: 24
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.
```swift
private class ContainerItemView: UIView {
var itemView: T
private let surfaceView: UIView = .init()
private var didTapHandler: (() -> ())?
}
```To create your customize ItemView, you create a view conforming to ItemType.
```swift
public protocol ItemType {
var text: Character? { get set }
var isHiddenCursor: Bool { get set }
func set(appearance: Appearance)
}
```About to set appearance.
```swift
public struct Appearance { }pinCodeInputView.set(appearance: )
```## Usage
```swift
import PinCodeInputView
```### standard
```swift// initialize
let pinCodeInputView: PinCodeInputView = .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
```swift
final class CustomItemView: UIView, ItemType {
var text: Character?
var isHiddenCursor: Bool
func set(appearance: Appearance) {}
// ...
}let pinCodeInputView: PinCodeInputView = .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