MhQnOTPField 1.0

MhQnOTPField 1.0

Mahmoud Qandeel 维护。



MhQnOTPField

MhQnOTPField 是一套文本框,可用于一次性密码、短信验证码、PIN 码等。所有字段都支持从短信中插入一次性代码。

MhQnOTPField 支持自动布局设计,并解决了其他包中存在的问题。

Mahmoud Qandeel 用 ❤️ 进行修改。

概览

需求

  • iOS 10.0+
  • Swift 5

安装

手动

只需将 Sources 文件夹添加到您的项目中。

CocoaPods

使用带有 Podfile 的 CocoaPods

pod 'MhQnOTPField', '~> 0.1'

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

Swift 包管理器

dependencies: [
    .package(url: "https://github.com/Mahmoud-Qandeel/MhQnOTPField", .upToNextMajor(from: "0.1"))
]

使用方法

🎨 示板

只需将 UITextField 放入其中,并将其类设置为 MhQnOTPField 之一。

💻 代码

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

文本颜色

只需像平常一样更改文本框的文本颜色。

光标颜色

着色色值负责光标颜色。如果您想隐藏光标,只需将其颜色设置为清除即可。

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

许可证

MhQnOTPField 在 MIT 许可下发布。有关详细信息,请参阅 LICENSE