MFAFloatLabel
Installation
MFAFloatLabel is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'MFAFloatLabel'
Usage
The UI component can be used via the MFAFloatLabel
or MFATextViewFloatLabel
classes. This control can be used very similar to UITextField
or UITextView
- both from Interface Builder, or from code.
Delegate
To use with UITextFieldDelegate
methods you should implement MFAFloatLabelDelegate
and set it on your MFAFloatLabel
.
textField.floatLabelDelegate = self
Font
You can customize the placeholder of your textField by changing the font name and size.
textField.placeholderCustomFontName = "Menlo"
textField.placeholderEditingFontSize = 10
Bottom border
textField.addBorder = true
textField.borderHeight = 1
textField.borderColor = .gray
Placeholder
textField.placeholderColor = .gray
textField.topSpacingFromPlaceholder = 6 // set the spacing bettwing text and placeholder when typing
Padding
textField.leftSpacing = 8 // left padding bettwing text/placeholder and left margin
textField.rightSpacing = 8 // right padding bettwing text/placeholder and right margin
Icon
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
Others
textField.onlyNumbers = false // set it true if your textField will accept only numbers
Formatting
We also provide custom format. Just set the mask and the character to be replaced
textField.setFormatting("(__) _____.____", replacementChar: "_")
And you can set it as secure text
textField.formatedSecureTextEntry = false
Author
matheusfrozzi, matheusfrozzi@gmail.com
License
MFAFloatLabel is available under the MIT license. See the LICENSE file for more info.