Skip to content

A fully configurable controller for validating a pin number.

License

Notifications You must be signed in to change notification settings

MacKaSL/MCKPinController

Repository files navigation

MCKPinController

A fully configurable controller for validating a pin number.

MCKPinController is a pin authentication controller written in Swift.

📱 iOS 9 or above

🔨 Swift 4

😃 Happy coding

Usage

Pods

source 'https://github.com/CocoaPods/Specs.git'
target '<TARGET_NAME>' do
  pod 'MCKPinController', '~> 1.0.5'
end

Features

Function configuration

Initiating configuraition

Make an instance of MCKConfiguration.

let config = MCKConfiguration()

All the configuration to the controller happens through the MCKConfiguration class.

You can configure how many digits will be entered.

config.numberOfDigits = 6

If you want to animate dots when you rest the pin, set true for shouldShakeOnReset. By default, this is set to false.

config.shouldShakeOnReset = true`

Listening to changes

You are able to listen to pin number changes.

config.pinChanged = { pin in
  print("pin changed \(pin)")
}

And once the whole pin number is entered, completion block will be called.

config.completion = { pin in
  print("Completed pin received: \(pin)")
}

Reset

When the entered pin number is wrong or at anytime, you are able to reset the controller with

MCKPinController.reset()

Top dots appearance configuration

You can configuration top dot appearance with MCKDotAppearance.

Properties:

fillingColor: UIColor
borderColor: UIColor
layerType: MCKLayerType

with MCKLayerType, you can configure dot type square or rounded. Default is set to rounded.

Example:

var dotAppearance = MCKDotAppearance()
dotAppearance.fillingColor = color
dotAppearance.borderColor = color
config.appearance.dots = dotAppearance

General view appearance configuration

Cofigure general appearance of the controller

Properties:

backgroundColor: UIColor
blurEffect: UIBlurEffect
imageTint: UIColor

Example:

var appearance = MCKGeneralAppearance()
appearance.imageTint = color
appearance.blurEffect = UIBlurEffect(style: .light)
config.appearance.general = appearance

Number pad appearance configuration

Configure the appearance of number pad

Properties:

fillingColor: UIColor
borderColor: UIColor
textColor: UIColor
borderWidth: CGFloat
backspaceTitle: String
backspaceImage: UIImage
layerType: MCKLayerType

When you want to have custom image or text on delete button, use below properties to configure it.

backspaceTitle: String
backspaceImage: UIImage

Note: If you set both image and text, only the image will appear. Only one at a time.

  1. Image
  2. Text

Example:

var numberPad = MCKNumberPadAppearance()
numberPad.textColor = color
numberPad.borderColor = color
numberPad.backspaceTitle = "↩︎"
config.appearance.numberPad = numberPad

with MCKLayerType, you can configure dot type square or rounded. Default is set to rounded.

Anyone is welcome to contribute...

Cheers 😃 📱 🔨

About

A fully configurable controller for validating a pin number.

Resources

License

Stars

Watchers

Forks

Packages

No packages published