UITextSubClass
This library is collection of UIText(View|Field) subclasses.
- a variety of subclass
- support iPad(
Installation
CocoaPods
pod 'UITextSubClass', :git => 'https://github.com/azu/UITextSubClass.git'
if you want to use one components, install specific subspec.
pod 'UITextSubClass/UITextFieldWithDatePicker'
UI Components Summary
UITextFieldWithPicker
UITextField + UIPickerView.
UITextFieldWithDatePicker
UITextField + UIDatePicker.
UITextFieldWithDecimalPad
UITextField + keyboardType = UIKeyboardTypeDecimalPad
+ treat decimal point.
You have to set significantFigures
.
@property (nonatomic) NSUInteger significantFigures;
UITextFieldWithNumberPad
UITextField + keyboardType = UIKeyboardTypeNumberPad
+ input control.
UITextFieldWithToolbar
UITextField + UIToolbar(inputAccessoryView)
UITextViewWithPlaceholder
UITextView + Placeholder + layer customized
#pragma mark - user defined runtime attributes
@property(nonatomic, strong) NSString *placeholderText;
@property(nonatomic, strong) UIColor *placeholderColor;
@property(nonatomic, strong) UILabel *placeholder;
// Those Property would only work with Storyboard - iOS5
@property(nonatomic, strong) UIColor *borderColor; // Color
@property(nonatomic, strong) UIColor *shadowColor; // Color
@property(nonatomic, strong) NSString *shadowOpacity; // Number (available decimal) eg. 1 or 0.5
@property(nonatomic, strong) NSString *borderWidth; // Number (available decimal) eg. 1 or 0.5
@property(nonatomic, strong) NSString *cornerRadius; // Number (available decimal) eg. 1 or 0.5
@property(nonatomic, strong) NSString *shadowRadius; // Number (available decimal) eg. 1 or 0.5
@property(nonatomic, strong) NSValue *shadowOffset; // CGSize
UITextViewWithToolbar
UITextViewWithPlaceholder + Toolbar
Usage
UITextFieldWithDatePicker
UITextFieldWithDatePicker is UITextField subclass
UITextFieldWithDatePicker *dateTextField = [[UITextFieldWithDatePicker alloc]init];
dateTextField.myDelegate = self;
// set DatePicker type
dateTextField.datePickerMode = UIDatePickerModeDate;
if setting UIDatePickerModeTime
, you should also set default minuteInterval :
dateTextField.minuteInterval = 60; // default minuteInterval
You can pass original UIDateFormatter:
(Defaults: use dateFormatFromTemplate:
)
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
dateTextField.dateFormatter = dateFormatter;
manually update TextField
[dateTextField updateText];
To get selected date
[dateTextField inputedDate];// <NSDate>
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
License
MIT