IOS: UITextField basics of uidesign, iosuitextfield
Simple Description: This control is generally used for the user's account, password, verification code, and other input windows that require short content
(Since I have just finished learning the control part, I have recently introduced various controls ..)
The main difference between UITextView and UITextField is that UITextField can set attributes related to InputText, for example, SecureInput and other attributes. UITextView can only implement basic text input functions, almost no content attribute can be set.
UITextField * TF = [[UITextField alloc] initWithFrame: CGRectMke (90,100,140, 25)]; // UITextField initialization:
[Self. window addSubview: TF]; // Add to view
TF. textColor = [UIColor redColor]; // enter the font color.
TF. delegate = self; // set the proxy. Add the proxy @ interface AppDelegate: UIResponder <UIApplicationDelegate, UITextFieldDelegate> to the. h file.
(Agent usage: 1. Listen to events that cannot be monitored through addTarget!
2. It is mainly used to transmit messages or data between two objects when some events occur)
TF. placeholder = @ "Enter Password:"; // If NO content is entered, a watermark font prompt is displayed.
TF. textColor = [UIColor reColor]; // enter the font color.
TF. secureTextEntry = YES; // whether the input content is visible
TF. tag = 101; // tag Value
TF. adjustsFontSizeToFitWidth = YES; // when the input character length is greater than the frame length, it is automatically reduced to adapt to the frame length
TF. background = [UIImage imageNamed: @ "***. jpg"]; // background. When using an image as the background, set TF. borderStyle to None.
TF. backgroundColor = [UIColor yellowColor]; // when the background is color, TF. borderStyle cannot be set to None
TF. borderStyle = UITextBorderStyleNone; // no style, right-angle border
UITextBorderStyleLine; // black border and Right Border
UITextBorderStyleBezel; // shadow, right-angle border
UITextBorderStyleRoundedRect; // corner Frame
[TF becomeFirstResponder]; // when a view is rendered, TF automatically becomes the first responder. the keyboard is displayed and can also be performed in the proxy method.
// The cross sign in the input box, in the format
TF. clearButtonMode = UITextFieldViewModeWhileEding; // displayed during editing
UITextFieldViewModeNever; // never appears
UITextFieldViewModeUnlessEditing; // when editing
UITextFieldViewModeAlways; // always appears
TF. autocorrectionType = UITextAutocorrectionTypeNo; // No Automatic Error Correction
UITextAutocorrectionTypeDefault; // default
UITextAutocorrectionTypeYes; // Automatic Error Correction
TF. clearsOnBeginEditing = YES; // when you click Edit again, whether to clear the last entered content. A proxy method is also available later.
// Set the pop-up keyboard type
TF. keyboardType = UIKeyboardTypeDefault; // default keyboard, supporting all characters
UIKeyboardTypeASCIICapable; // supports the default ASCII keyboard.
UIKeyboardTypeNumbersAndPunctuation; // standard phone keyboard, supporting + * # characters
UIKeyboardTypeURL; // The URL keyboard. The. com button supports only URL characters.
UIKeyboardTypeNumberPad; // numeric keypad
UIKeyboardTypePhonePad; // telephone keyboard
UIKeyboardTypeNamePhnoePad; // enter the name of a person on the phone keyboard.
UIKeyboardTypeEmailAddress; // email keyboard
UIKeyboardTypeDecimalPad; // numeric keyboard with decimal point
UIKeyboardTypeTwitter; // optimizes the keyboard
// Whether the first letter is capitalized
TF. autocapitalizationType = UITextAutocapitalizationTypeNone; // The value is not automatically capitalized.
UITextAutocapitalizationTypeWords,; // uppercase letters
UITextAutocapitalizationTypeSentences; // The first letter of a sentence is capitalized.
UITextAutocapitalizationTypeAllCharacters; // all uppercase letters
// What is the return key?
TF. returnKeyType = UIReturnKeyDone; // the blue button marked with Done
UIReturnKeyDefault; // The default gray button marked with Return
UIReturnKeyGo; // the blue button marked with Go
UIReturnKeyGoogle; // the blue button marked with Google, term search
UIReturnKeyJoin; // the blue button marked with Join
UIReturnKeyNext; // the blue button marked with Next
UIReturnKeyRoute; // the blue button marked with Route
UIReturnKeySearch; // the blue button marked with Search
UIReturnKeySend; // the blue button marked with "Send"
UIReturnKeyYahoo; // the blue button marked with Yahoo
UIReturnKeyYahoo; // the blue button marked with Yahoo
UIReturnKeyEmergencyCall; // emergency call button
// Proxy method of UITextField (proxy needs to be set first) Pay attention to whether to set the return value
-(BOOL) textFieldShouldBeginEditing :( UITextField *) textField; // The method used when the user clicks and prepares to edit the content. The window is displayed.
-(Void) textFieldDidBeginEditing :( UITextField *) textField; // This proxy method is used when the user starts editing
-(BOOL) textFieldShouldEndEditing :( UITextField *) textField; // This proxy method is used when the user is about to end editing.
-(Void) textFieldDidEndEditing :( UITextField *) textField; // This proxy method is used when the user finishes editing.
-(BOOL) textField :( UITextField *) textField shouldChangeCharactersInRange :( nsange) range replacementString :( NSString *) string
{
If (range. location> = 6 ){
Return NO;
} Else
Return YES;
} // This method is called when the user uses the automatic correction function to modify the input text to the recommended text, or to limit the input length.
-(BOOL) textFieldShouldClear :( UITextField *) textField; // This proxy method is used when the input content is cleared.
-(BOOL) textFieldShouldReturn :( UITextField *) textField; // This proxy method is used when you click Return on the keyboard to collapse the keyboard.
(You may have learned a little. If you have any additional information, you can leave a message. If you have any questions, you can contact QQ790444804: hgwchihuo.
------- I am a happy little tail '(* ← _ ← *)′)