MFAFloatLabel is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'MFAFloatLabel'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.
To use with UITextFieldDelegate methods you should implement MFAFloatLabelDelegate and set it on your MFAFloatLabel.
textField.floatLabelDelegate = selfYou can customize the placeholder of your textField by changing the font name and size.
textField.placeholderCustomFontName = "Menlo"
textField.placeholderEditingFontSize = 10textField.addBorder = true
textField.borderHeight = 1
textField.borderColor = .graytextField.placeholderColor = .gray
textField.topSpacingFromPlaceholder = 6 // set the spacing bettwing text and placeholder when typingtextField.leftSpacing = 8 // left padding bettwing text/placeholder and left margin
textField.rightSpacing = 8 // right padding bettwing text/placeholder and right margintextField.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 = 12textField.onlyNumbers = false // set it true if your textField will accept only numbersWe 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 = falsematheusfrozzi, [email protected]
MFAFloatLabel is available under the MIT license. See the LICENSE file for more info.
