MhQnOTPField 是一套文本框,可用于一次性密码、短信验证码、PIN 码等。所有字段都支持从短信中插入一次性代码。
MhQnOTPField 支持自动布局设计,并解决了其他包中存在的问题。
由 Mahmoud Qandeel 用 ❤️ 进行修改。
- iOS 10.0+
- Swift 5
只需将 Sources
文件夹添加到您的项目中。
使用带有 Podfile 的 CocoaPods
pod 'MhQnOTPField', '~> 0.1'
# individual page control
pod 'MhQnOTPField/One'
pod 'MhQnOTPField/Two'
pod 'MhQnOTPField/Three'
pod 'MhQnOTPField/Four'
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
只需像平常一样更改文本框的文本颜色。
着色色值负责光标颜色。如果您想隐藏光标,只需将其颜色设置为清除即可。
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
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
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
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。