UITextField, uitextfield multiple rows

Source: Internet
Author: User

UITextField, uitextfield multiple rows

// 1. UITextField * textField = [[UITextField alloc] initWithFrame: CGRectMake (30,100,260, 40)]; // 2. // textField. backgroundColor = [UIColor redColor]; // attribute // set the text color: textColor textField. textColor = [UIColor redColor]; // border status: borderStyle/* 1, border rounded corner 2, UITextBorderStyleLine black rectangular border 3, UITextBorderStyleBezel gray rectangular border 4, UITextBorderStyleNone no border */textField. borderStyle = UITextBord ErStyleRoundedRect; // horizontal alignment of text: textField is left aligned by default. textAlignment = NSTextAlignmentLeft; // text vertical alignment: contentverticalignment center textField by default. contentverticalignment = UIControlContentVerticalAlignmentCenter; // set the font size: font textField. font = [UIFont systemFontOfSize: 20.0]; // adaptive text size: adjustsFontSizeToFitWidth textField. adjustsFontSizeToFitWidth = YES; // set the minimum font size: minimumFontSize textField. minimumFontS Ize = 20.0; // default text: text textField. text = @ "hello world"; // prompt text: placeholder textField. placeholder = @ "Enter the Account"; // ciphertext: secureTextEntry textField. secureTextEntry = NO; // whether the input box is available: enabled textField. enabled = YES; // type of the return key: returnKeyType/* 1, UIReturnKeyDefault return 2, UIReturnKeyDone Done 3, receivemergencycall 4, UIReturnKeyGoogle = response = UIReturnKeySearch 5, UIReturn KeyJoin Join... */textField. returnKeyType = UIReturnKeyJoin; // keyboard type: keyboardType/* 1. UIKeyboardTypeDefault number, symbol, Chinese and English 2. UIKeyboardTypeNumberPad keypad 3. UIKeyboardTypeWebSearch URL. 4. UIKeyboardTypeURL. com /. 5. UIKeyboardTypeEmailAddress @. 6. UIKeyboardTypeNumbersAndPunctuation digital symbol... */textField. keyboardType = UIKeyboardTypeDefault; // keyboard color: keyboardAppearance/* 1. UIKeyboardAppearanceDe Fault = UIKeyboardAppearanceLight light gray 2, UIKeyboardAppearanceAlert = UIKeyboardAppearanceDark dark gray */textField. keyboardAppearance = UIKeyboardAppearanceDefault; // background image: when the border status is rounded, the background image textField is invalid. background = [UIImage imageNamed: @ "map.png"]; // One-Click Clear button: clearButtonMode/* 1. UITextFieldViewModeAlways always appear. 2. UITextFieldViewModeNever never appears. 3. When the text is edited in, disappear when not edited. 4. UIText FieldViewModeUnlessEditing disappears when the text is edited in the input box. */textField appears when the text is not edited. clearButtonMode = UITextFieldViewModeUnlessEditing; // re-edit whether to clear the text before: clearsOnBeginEditing YES: Clear textField. clearsOnBeginEditing = YES; // whether to enable automatic capitalization: autocapitalizationType/* 1. All letters in tags are capitalized. 2. All letters in UITextAutocapitalizationTypeNone are not capitalized. 3. The first letter in each sentence is capitalized. 4. TypeWords: uppercase letters */textField. autocapitalizationType = UITextAutocapitalizationTypeWords; // whether automatic error correction is performed: autocorrectionType/* 1. UITextAutocorrectionTypeDefault default. 2. Disable Error Correction. 3. UITextAutocorrectionTypeYes error correction. autocorrectionType = UITextAutocorrectionTypeYes; // set the Left view: leftView // set the location to invalid UIView * view = [[UIView alloc] initWithFrame: CGRectMake (0, 0, 40, 40)]; view. backgr OundColor = [UIColor redColor]; textField. leftView = view; // The status of the Left view: leftViewMode textField. leftViewMode = UITextFieldViewModeAlways; // set the right view: rightView UIView * view2 = [[UIView alloc] initWithFrame: CGRectMake (0, 0, 40, 40)]; view2.backgroundColor = [UIColor yellowColor]; // textField. rightView = view2; // The Status of the right view: rightViewMode // textField. rightViewMode = UITextFieldViewModeAlways; // different positions. The same view cannot be used. // View on the keyboard: inputAccessoryView UIView * view3 = [[UIView alloc] initWithFrame: CGRectMake (0, 0,320, 40)]; view3.backgroundColor = [UIColor purpleColor]; textField. inputAccessoryView = view3; // obtain the text in the input box: textField. text NSString * str = textField. text; NSLog (@ "% @", str );/**************!!!!!! Delegate !!!!!!! * ************/TextField. delegate = self; [textField becomeFirstResponder]; // 3. [self. view addSubview: textField]; # pragma mark-UITextFieldDelegate // return key method *****-(BOOL) textFieldShouldReturn :( UITextField *) textField {// The input box loses response: the keyboard is retracted and the cursor disappears. [textField resignFirstResponder]; // The input box starts to respond. The keyboard appears, and the cursor appears. // [textField becomeFirstResponder]; return YES ;} // one-click Delete button method-(BOOL) textFieldShouldClear :( UITextField *) textField {// return YES: one-click Delete valid return NO: one-click Delete invalid if ([textField. text isEqualToString: @ "123"]) {return NO;} return YES;} // whether the input box can be edited-(BOOL) textFieldShouldBeginEditing :( UITextField *) textField {return YES ;} // can the input box end editing **-(BOOL) textFieldShouldEndEditing :( UITextField *) textField {if (textField. text. length <11) {return NO;} return YES;} // method called when the input box starts responding ***-(void) textFieldDidBeginEditing :( UITextField *) textField {NSLog (@ "textFieldDidBeginEditing");} // method called when the input box ends the response ***-(void) textFieldDidEndEditing :( UITextField *) textField {NSLog (@ "textFieldDidEndEditing");} // page Jump // The first parameter: the page to be redirected // The second parameter: with no animation effect // The third parameter: The operation performed after the jump ends // instantiate the second page SecondViewController * second = [[SecondViewController alloc] init]; // jump operation: [self presentViewController: second animated: YES completion: ^ {// NSLog (@ "second") ;}] appears from the bottom up; // return to the previous page: disappear from top to bottom [self dismissViewControllerAnimated: YES completion: ^ {//}]; // page lifecycle // The page is about to appear-(void) viewWillAppear :( BOOL) animated {[super viewWillAppear: animated]; NSLog (@ "1");} // The page displays-(void) viewDidAppear :( BOOL) animated {[super viewDidAppear: animated]; NSLog (@ "2");} // The page is about to disappear-(void) viewWillDisappear :( BOOL) animated {[super viewWillDisappear: animated]; NSLog (@ "3 ");} // The page has disappeared-(void) viewDidDisappear :( BOOL) animated {[super viewDidDisappear: animated]; NSLog (@ "4 ");}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.