YTFloatingTitleTextField
YTFloatingTitleTextField is a subclass of UITextField implemented in Objective-C. It is customizable, easy to use, and supported to use programatically or through Interface Builder. Using YTFloatingTitleTextField you'll be able to:
- Enable floating title while editing
- Enable showing bottom line
- Use different texts for
titleandplaceholder - Use different styles for corresponding status (normal or error)
Usage
Through Interface Builder
- Drag a
UITextFieldcomponent into your view controller - Go to
Identity Inspector > Custom Classand change the class name toYTFloatingTitleTextField
Perks to use Interface Builder -- some default configurations we did for you:
titlewill be set to be the same asplaceholdernormalTextColorwill be set to be the same astextColornormalTextFontwill be set to be the same asfontnormalLineColorwill be set to be the same astintColor
In Code
It's also really easy to use in code:
YTFloatingTitleTextField *textField = [[YTFloatingTitleTextField alloc]
initWithFrame:CGRectMake(40, 150, 200, 60)];
textField.title = @"Name";
textField.placeholder = @"What's your name?";
textField.textAlignment = NSTextAlignmentCenter;
[self.view addSubview:textField];Example
To run the example project, clone the repo, and run pod install from the Example directory first.
Requirements
iOS 8.0+
Installation
CocoaPods
If CocoaPods isn't installed yet, you can do it by running:
$ gem install cocoapodsThen simply add the following line to your Podfile:
pod 'YTFloatingTitleTextField'License
YTFloatingTitleTextField is available under the MIT license. See the LICENSE file for more info.
