FAFloatLabeledTextInput
Overview
A Swift 4.2 implementation of the UX pattern known as the "Float Label Pattern".
FAFloatLabeledTextInput
includes subclasses for both UITextField
and UITextView
. Additionally, it provides a UITableViewCell
subclass for each thats ready to work out of the box, and the FAFloatLabeledTextViewTableViewCell
is configured to grow as needed to accommodate text.
This design was heavily inspired by @jverdi's JVFloatLabeledTextField and @aksswami's FloatLabelFields.
Standard Example
UITableViewCell Example
Usage
Simply use FAFloatLabledTextField
or FAFloatLabledTextView
in place of UITextField
or UITextView
.
The UITableViewCell
subclasses can be used directly in code, or in Interface Builder by setting the prototype cell's class to either FAFloatLabeledTextFieldTableViewCell
or FAFloatLabeledTextViewTableViewCell
.
let titleField = FAFloatLabelTextField()
titleField.placeholder = "Title"
titleField.placeholderFont = .systemFont(ofSize: 16.0)
titleField.floatingLabelFont = .boldSystemFont(ofSize: 11.0)
let description = FAFloatLabelTextView()
descriptionField.placeholder = "Description"
descriptionField.placeholderFont = .systemFont(ofSize: 16.0)
descriptionField.floatingLabelFont = .boldSystemFont(ofSize: 11.0)
The code is well documented, and there are many options available, so I encourage you to give it a read.
Example Project
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
This component uses Swift 4.2, which means it requires iOS 7 or later.
Installation
FAFloatLabeledTextInput is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'FAFloatLabeledTextInput'
Author
Ideas? Questions? Open an issue, or hit me up on Twitter.
License
FAFloatLabeledTextInput is available under the MIT license. See the LICENSE file for more info.