AHTextField
屏幕截图
示例
要运行 example 项目,首先克隆仓库,然后从 Example 目录运行 pod install
要求
iOS 9.0+
使用
AHTextField 的示例
lazy var textField: AHTextField = {
let textField = AHTextField(textPadding: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 15))
textField.translatesAutoresizingMaskIntoConstraints = false
textField.setLeftViewImage(image: UIImage(named: "lock"), size: CGSize(width: 25, height: 25), tintColor: .gray)
textField.setRightViewImage(image: UIImage(named: "cancel"), size: CGSize(width: 30, height: 30), tintColor: appleRed)
textField.leftViewPadding.left = 8
textField.setBorders(width: 2, color: .blue)
textField.placeholder = "Password"
return textField
}()
使用默认文本填充初始化
let textField = AHTextField(textPadding: UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15))
添加图片
textField.setLeftViewImage(image: image1, size: CGSize(width: 25, height: 25), tintColor: .gray)
textField.setRightViewImage(image: image2, size: CGSize(width: 30, height: 30), tintColor: .red, backgroundColor: .blue)
设置边框
textField.setBorders(for: [.bottom], width: 3, gradient: gradientLayer)
注意:梯度层将被复制 => 可以将一个梯度层作为参数传递给多个文本字段
或者
textField.setBorders(width: 2, color: appleBlue)
填充
您可以更改填充,如果默认值不适合
textField.leftViewPadding.left = 8
textField.clearButtonPadding.right = 15
textField.rightViewPadding.right = 10
安装
AHTextField可以通过CocoaPods使用。要安装它,只需将以下行添加到您的Podfile中
pod 'AHTextField'
作者
Aleš Hanžlík,[email protected]
许可证
AHTextField遵循MIT许可协议。更多详情请查看LICENSE文件。