MCKPinController is a pin authentication controller written in Swift.
📱 iOS 9 or above
🔨 Swift 4
😃 Happy coding
source 'https://github.com/CocoaPods/Specs.git'
target '<TARGET_NAME>' do
pod 'MCKPinController', '~> 1.0.5'
end
- Function configuration
- Top dots appearance configuration
- General view appearance configuration
- Number pad appearance configuration
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`
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)")
}
When the entered pin number is wrong or at anytime, you are able to reset the controller with
MCKPinController.reset()
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
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
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.
- Image
- 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...