EGFloatingTextField 0.0.1

EGFloatingTextField 0.0.1

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布最新发布2015年9月
SPM支持 SPM

Enis Gayretli 维护。



EGFloatingTextField

Swift 编程语言中对 Material Design 中“浮动标签模式”的实现。

alt tag

在您的项目中使用此功能

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 许可证