MFAFloatLabel 1.0.0

MFAFloatLabel 1.0.0

Uriel BattanoliMatheus Frozzi 维护。



  • matheusfrozzi

MFAFloatLabel

Version License Platform

安装

MFAFloatLabel 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile

pod 'MFAFloatLabel'

使用方法

该 UI 组件可以通过 MFAFloatLabelMFATextViewFloatLabel 类使用。该控件可以非常类似于 UITextFieldUITextView 使用,无论是否从 Interface Builder 还是代码中。

字体

您可以将占位符字体名称更改为与 textField 文本不同。在输入时还可以更改占位符的字体大小。

textField.placeholderCustomFontName = "Menlo"
textField.placeholderEditingFontSize = 10

底部边框

textField.addBorder = true
textField.borderHeight = 1
textField.borderColor = .gray

占位符

textField.placeholderColor = .gray
textField.topSpacingFromPlaceholder = 6 // set the spacing bettwing text and placeholder when typing

填充

textField.leftSpacing = 8 // left padding bettwing text/placeholder and left margin
textField.rightSpacing = 8 // right padding bettwing text/placeholder and right margin

图标

textField.icon = #imageLiteral(resourceName: "icon")
textField.iconAtTrailing = true // set it false if you want icon on right
textField.iconSpacing = 8 // spacing bettwing icon and margin
textField.iconWidth = 12
textField.iconHeight = 12

其他

textField.onlyNumbers = false // set it true if your textField will accept only numbers

格式化

我们还提供自定义格式。只需设置掩码和要替换的字符。

textField.setFormatting("(__) _____.____", replacementChar: "_")

您还可以将其设置为安全文本。

textField.formatedSecureTextEntry = false

作者

matheusfrozzi, [email protected]

许可协议

MFAFloatLabel 在 MIT 许可协议下可用。有关更多信息,请参阅 LICENSE 文件。