@@ -561,7 +561,7 @@ - (SCLSwitchView *)addSwitchViewWithLabel:(NSString *)label
561561
562562#pragma mark - TextField
563563
564- - (SCLTextView *)addTextField : (NSString *)title
564+ - (SCLTextView *)addTextField : (NSString *)title setDefaultText : ( NSString *) defaultText
565565{
566566 [self addObservers ];
567567
@@ -577,6 +577,10 @@ - (SCLTextView *)addTextField:(NSString *)title
577577 {
578578 txt.placeholder = title;
579579 }
580+ if (defaultText != nil )
581+ {
582+ txt.text = defaultText;
583+ }
580584
581585 [_contentView addSubview: txt];
582586 [_inputs addObject: txt];
@@ -1637,12 +1641,14 @@ - (void)setupFluent {}
16371641@interface SCLALertViewTextFieldBuilder ()
16381642#pragma mark - Parameters
16391643@property (copy , nonatomic ) NSString *parameterTitle;
1644+ @property (copy , nonatomic ) NSString *parameterDefaultText;
16401645
16411646#pragma mark - Available later after adding
16421647@property (weak , nonatomic ) SCLTextView *textField;
16431648
16441649#pragma mark - Setters
16451650@property (copy , nonatomic ) SCLALertViewTextFieldBuilder *(^title) (NSString *title);
1651+ @property (copy , nonatomic ) SCLALertViewTextFieldBuilder *(^defaultText) (NSString *defaultText);
16461652@end
16471653
16481654@implementation SCLALertViewTextFieldBuilder
@@ -1652,13 +1658,18 @@ - (void)setupFluent {
16521658 weakSelf.parameterTitle = title;
16531659 return weakSelf;
16541660 };
1661+ self.defaultText = ^(NSString *defaultText){
1662+ weakSelf.parameterDefaultText = defaultText;
1663+ return weakSelf;
1664+ };
16551665}
16561666@end
16571667
16581668@interface SCLALertViewButtonBuilder ()
16591669
16601670#pragma mark - Parameters
16611671@property (copy , nonatomic ) NSString *parameterTitle;
1672+ @property (copy , nonatomic ) NSString *parameterDefaultText;
16621673@property (weak , nonatomic ) id parameterTarget;
16631674@property (assign , nonatomic ) SEL parameterSelector;
16641675@property (copy , nonatomic ) void (^parameterActionBlock)(void );
@@ -1669,6 +1680,7 @@ @interface SCLALertViewButtonBuilder()
16691680
16701681#pragma mark - Setters
16711682@property (copy , nonatomic ) SCLALertViewButtonBuilder *(^title) (NSString *title);
1683+ @property (copy , nonatomic ) SCLALertViewButtonBuilder *(^defaultText) (NSString *defaultText);
16721684@property (copy , nonatomic ) SCLALertViewButtonBuilder *(^target) (id target);
16731685@property (copy , nonatomic ) SCLALertViewButtonBuilder *(^selector) (SEL selector);
16741686@property (copy , nonatomic ) SCLALertViewButtonBuilder *(^actionBlock) (void (^actionBlock)(void ));
@@ -1683,6 +1695,10 @@ - (void)setupFluent {
16831695 weakSelf.parameterTitle = title;
16841696 return weakSelf;
16851697 };
1698+ self.defaultText = ^(NSString *defaultText){
1699+ weakSelf.parameterDefaultText = defaultText;
1700+ return weakSelf;
1701+ };
16861702 self.target = ^(id target){
16871703 weakSelf.parameterTarget = target;
16881704 return weakSelf;
@@ -1822,8 +1838,8 @@ - (void)setupFluent {
18221838 [weakSelf.alertView addCustomView: view];
18231839 return weakSelf;
18241840 };
1825- self.addTextField = ^(NSString *title) {
1826- [weakSelf.alertView addTextField: title];
1841+ self.addTextField = ^(NSString *title, NSString *defaultText ) {
1842+ [weakSelf.alertView addTextField: title setDefaultText: defaultText ];
18271843 return weakSelf;
18281844 };
18291845 self.addCustomTextField = ^(UITextField *textField) {
@@ -1879,7 +1895,7 @@ - (void)setupFluent {
18791895 };
18801896
18811897 self.addTextFieldWithBuilder = ^(SCLALertViewTextFieldBuilder *builder){
1882- builder.textField = [weakSelf.alertView addTextField: builder.parameterTitle];
1898+ builder.textField = [weakSelf.alertView addTextField: builder.parameterTitle setDefaultText: builder.parameterDefaultText ];
18831899 return weakSelf;
18841900 };
18851901}
@@ -1916,6 +1932,7 @@ @interface SCLAlertViewShowBuilder()
19161932@property (copy , nonatomic ) UIImage *parameterImage;
19171933@property (copy , nonatomic ) UIColor *parameterColor;
19181934@property (copy , nonatomic ) NSString *parameterTitle;
1935+ @property (copy , nonatomic ) NSString *parameterDefaultText;
19191936@property (copy , nonatomic ) NSString *parameterSubTitle;
19201937@property (copy , nonatomic ) NSString *parameterCompleteText;
19211938@property (copy , nonatomic ) NSString *parameterCloseButtonTitle;
0 commit comments