测试已测试 | ✗ |
Lang语言 | SwiftSwift |
许可证 | MIT |
发布最新发布 | 2015年9月 |
SPM支持 SPM | ✗ |
由 Enis Gayretli 维护。
Swift 编程语言中对 Material Design 中“浮动标签模式”的实现。
Add vendors, PureLayout at "https://github.com/smileyborg/PureLayout" and UIKit+Material at "https://github.com/nklizhe/UIKit-Material".
Add EGFloatingTextField.swift into your project.
初始化文本框并将其添加为子视图
let emailLabel = EGFloatingTextField(frame: CGRectMake(8, 64, CGRectGetWidth(self.view.bounds) - 16, 48))
// set as floatinglabel
emailLabel.floatingLabel = true
// set the placeholder
emailLabel.setPlaceHolder("Email")
// set the validation type there are two options at the moment, Email and Number.
emailLabel.validationType = .Email
// add as subview
self.view.addSubview(emailLabel)
为文本框创建自定义验证器
为 EGFloatingTextFieldValidationType 枚举添加新情况
enum EGFloatingTextFieldValidationType {
case Email
case Number
case X
}
为验证类型创建验证块
private var xValidationBlock : EGFloatingTextFieldValidationBlock
在 commitInit 方法中实现验证块
func commonInit(){
self.xValidationBlock = ({(text:String, inout message: String) -> Bool in
....
})
.....
}
MIT 许可证