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
title
andplaceholder
- Use different styles for corresponding status (normal or error)
- Drag a
UITextField
component into your view controller - Go to
Identity Inspector > Custom Class
and change the class name toYTFloatingTitleTextField
Perks to use Interface Builder -- some default configurations we did for you:
title
will be set to be the same asplaceholder
normalTextColor
will be set to be the same astextColor
normalTextFont
will be set to be the same asfont
normalLineColor
will be set to be the same astintColor
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];
To run the example project, clone the repo, and run pod install
from the Example directory first.
iOS 8.0+
If CocoaPods isn't installed yet, you can do it by running:
$ gem install cocoapods
Then simply add the following line to your Podfile:
pod 'YTFloatingTitleTextField'
YTFloatingTitleTextField
is available under the MIT license. See the LICENSE file for more info.