iOS的表单框架:SwiftyFORM

jopen 9年前

SwiftyFORM 是一个采用Swift开发的 iOS 表单框架。

特性:

  • 在一个 form 中,有 12 个 form items 可使用。

  • 可在多行中排列文本区域。

  • 表单验证规则引擎

  • 有问题的验证显示有红色文字

iOS的表单框架:SwiftyFORM

import SwiftyFORM    class ChangePasswordViewController: FormViewController {      override func populate(builder: FormBuilder) {          builder.navigationTitle = "Password"          builder += SectionHeaderTitleFormItem().title("Your Old Password")          builder += passwordOld          builder += SectionHeaderTitleFormItem().title("Your New Password")          builder += passwordNew          builder += passwordNewRepeated          builder.alignLeft([passwordOld, passwordNew, passwordNewRepeated])      }        lazy var passwordOld: TextFieldFormItem = {          let instance = TextFieldFormItem()          instance.title("Old password").password().placeholder("required")          instance.keyboardType = .NumberPad          instance.autocorrectionType = .No          instance.validate(CharacterSetSpecification.decimalDigitCharacterSet(), message: "Must be digits")          instance.submitValidate(CountSpecification.min(4), message: "Length must be minimum 4 digits")          instance.validate(CountSpecification.max(6), message: "Length must be maximum 6 digits")          return instance          }()        lazy var passwordNew: TextFieldFormItem = {          let instance = TextFieldFormItem()          instance.title("New password").password().placeholder("required")          instance.keyboardType = .NumberPad          instance.autocorrectionType = .No          instance.validate(CharacterSetSpecification.decimalDigitCharacterSet(), message: "Must be digits")          instance.submitValidate(CountSpecification.min(4), message: "Length must be minimum 4 digits")          instance.validate(CountSpecification.max(6), message: "Length must be maximum 6 digits")          return instance          }()        lazy var passwordNewRepeated: TextFieldFormItem = {          let instance = TextFieldFormItem()          instance.title("Repeat password").password().placeholder("required")          instance.keyboardType = .NumberPad          instance.autocorrectionType = .No          instance.validate(CharacterSetSpecification.decimalDigitCharacterSet(), message: "Must be digits")          instance.submitValidate(CountSpecification.min(4), message: "Length must be minimum 4 digits")          instance.validate(CountSpecification.max(6), message: "Length must be maximum 6 digits")          return instance          }()  }

项目主页:http://www.open-open.com/lib/view/home/1435817954122