CHIOTPField 0.1.0

CHIOTPField 0.1.0

Chili iOS 维护。



  • 作者
  • Chili

CHIOTPField

CHIOTPField 是一组可以用于一次性密码、短信验证码、PIN 码等文本字段。所有字段都支持从短信中插入一次性密码。

❤️Chili Labs 创建。

概述

要求

  • iOS 10.0+
  • Swift 5

安装

手动

只需将 Source 文件夹添加到项目中即可。

CocoaPods

使用 Podfile 配合 CocoaPods

pod 'CHIOTPField', '~> 0.1'

# individual page control
pod 'CHIOTPField/One'
pod 'CHIOTPField/Two'
pod 'CHIOTPField/Three'
pod 'CHIOTPField/Four'

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/ChiliLabs/CHIOTPField.git", .upToNextMajor(from: "0.1"))
]

使用说明

🎨Storyboard

只需将 UITextField 的类设置为 CHIOTPField 之一的类。

💻代码

let field = CHIOTPFieldOne(frame: .init(x: 0, y: 0, width: 200, height: 60))
field.numberOfDigits = 4
field.cornerRadius = 4

文本颜色

像平常一样更改文本字段的文本颜色。

光标颜色

着色颜色负责光标颜色。如果想要隐藏光标,只需设置颜色为 clear。

OTP 字段

OTPFieldOne

var numberOfDigits: Int // number of boxes for digits
var spacing: Int // spacing between digits
var boxBackgroundColor: UIColor // background color of the box in normal state
var borderColor: UIColor // border color of the box in normal state
var cornerRadius: CGFloat // corner radius of the box
var activeShadowColor: UIColor? // shadow color of the box in active state
var activeShadowOpacity: CGFloat // shadow opacity of the box in active state
var boxPlaceholder: String? // placeholder text
var boxPlaceholderColor: UIColor? // placeholder text color

OTPFieldTwo

var numberOfDigits: Int // number of boxes for digits
var spacing: Int // spacing between digits
var cornerRadius: CGFloat // corner radius of the box
var boxBackgroundColor: UIColor // background color of the box in normal state
var activeBoxBackgroundColor: UIColor // background color of the box in active state
var filledBoxBackgroundColor: UIColor // background color of the box if a text is entered
var borderColor: UIColor // border color of the box in normal state
var activeBorderColor: UIColor? // border color of the box in active
var filledBorderColor: UIColor? // border color of the box if a text is entered
var boxPlaceholder: String? // placeholder text
var boxPlaceholderColor: UIColor? // placeholder text color

OTPFieldThree

var numberOfDigits: Int // number of boxes for digits
var spacing: Int // spacing between digits
var boxBackgroundColor: UIColor // background color of the box in normal state
var borderHeight: CGFloat / /bottom border height
var borderCornerRadius: CGFloat // bottom border radius
var dotRadius: CGFloat // dot radius when text is entered

OTPFieldFour

var numberOfDigits: Int // number of boxes for digits
var spacing: Int // spacing between digits
var boxBackgroundColor: UIColor // background color of the box in normal state
var borderHeight: CGFloat / /bottom border height
var borderColor: CGFloat // bottom border color
var cornerRadius: CGFloat // corner radius of the box

授权

CHIOTPField遵循MIT授权协议发布。详见授权文件