MaterialOutlinedTextField

一个简单的 Swift 实现的 Material Design 轮廓文本字段

安装

可以使用 Swift Package Manager 进行安装。 在 Xcode 中,转到 File > Swift Packages > Add Package Dependency… 并粘贴存储库 URL (https://github.com/flowbe/MaterialOutlinedTextField) 来添加它。

您也可以直接在您的 Package.swift 文件中添加依赖项

dependencies: [
    .package(url: "https://github.com/flowbe/MaterialOutlinedTextField.git", .upToNextMajor(from: "0.1.0"))
]

用法

MaterialOutlinedTextField 具有与 UITextField 相同的接口,但增加了一些额外的属性和方法

示例

let t = MaterialOutlinedTextField(frame: CGRect(x: 0, y: 0, width: 200, height: 56))
textField.label.text = "Label"
textField.placeholder = "Placeholder"
textField.clearButtonMode = .whileEditing
textField.setColorModel(ColorModel(textColor: .gray, floatingLabelColor: .gray, normalLabelColor: .gray, outlineColor: .gray), for: .normal)
textField.setColorModel(ColorModel(textColor: .systemBlue, floatingLabelColor: .systemBlue, normalLabelColor: .systemBlue, outlineColor: .systemBlue), for: .editing)
textField.setColorModel(ColorModel(with: .disabled), for: .disabled)