https://github.com/inloop/pinindicatorview
A simple UI component that mimics the lock screen pin indicator
https://github.com/inloop/pinindicatorview
Last synced: 10 months ago
JSON representation
A simple UI component that mimics the lock screen pin indicator
- Host: GitHub
- URL: https://github.com/inloop/pinindicatorview
- Owner: inloop
- License: mit
- Created: 2018-02-20T15:09:24.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-21T07:44:25.000Z (almost 8 years ago)
- Last Synced: 2024-10-15T04:06:06.532Z (over 1 year ago)
- Language: Swift
- Size: 14.6 KB
- Stars: 6
- Watchers: 10
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# PinIndicatorView
A simple UI component that mimics the lock screen pin indicator
## Usage
Import the framework
```
import PinIndicatorView
```
Add the `PinIndicatorView` view to your storyboard and create an outlet
```
@IBOutlet weak var pinIndicator: PinIndicatorView!
```
You can set the required number of digits and the colour. The defaults are 4 and blue. You can either set this programatically or in your storyboard
```
pinIndicator.digitCount = 8
pinIndicator.color = .green
```
Fill or unfill the indicator when digit or backspace buttons are pressed
```
pinIndicator.addDigit()
pinIndicator.deleteDigit()
```
You can check if the required number of digits was inputted
```
pinIndicator.isFilled
```
If your validation fails trigger the shake animation and clear the indicator
```
pinIndicator.shake()
pinIndicator.clear()
```
## Instalation
The library is available on cocoapods
```
pod 'PinIndicatorView', '~> 1.0'
```
## Customisation
You can customise the indicator by supplying a custom renderer. The renderer implements the `IndicatorRenderer` protocol and is assigned to the `renderer` property of the indicator.
```
class MyIndicatorRenderer: IndicatorRenderer {
func renderFilled(in rect: CGRect, context: CGContext) {
// TODO: Draw the filled shape
}
func renderEmpty(in rect: CGRect, context: CGContext) {
// TODO: Draw the outline
}
}
```