Home >Java >javaTutorial >What does textfield mean?
Textfield means "text box; text field; text field; text area; text field". It is a text box component in the java Swing desktop application, which can realize text input and output. Textfield has Many functional methods can be used to enrich the component.
textfield has many functional methods, here are some of them:
Initialize textfield and set the position and size
UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(20, 20, 130, 30)];
Set the border style. The border style will be displayed only if it is set.
text.borderStyle = UITextBorderStyleRoundedRect; typedef enum { UITextBorderStyleNone, UITextBorderStyleLine, UITextBorderStyleBezel, UITextBorderStyleRoundedRect } UITextBorderStyle;
Set the background color of the input box. If it is set to white, the border will be ignored if a custom background image is used.
text.backgroundColor = [UIColor whiteColor];
Set background
text.background = [UIImage imageNamed:@"dd.png"];
Set background
text.disabledBackground = [UIImage imageNamed:@"cc.png"];
When the input box has no content, the watermark prompt content is password
text.placeholder = @"password";
Set the font style and size of the input box content
text.font = [UIFont fontWithName:@"Arial" size:20.0f];
Set the font color
text.textColor = [UIColor redColor];
Whether there is a cross in the input box and when it will be displayed , used to delete the content in the input box at one time
text.clearButtonMode = UITextFieldViewModeAlways; typedef enum {UITextFieldViewModeNever, 重不出现UITextFieldViewModeWhileEditing, 编辑时出现UITextFieldViewModeUnlessEditing, 除了编辑外都出现UITextFieldViewModeAlways 一直出现} UITextFieldViewMode;
The text that exists at the beginning of the input box
text.text = @"一开始就在输入框的文字";
Every time a character is entered, it becomes a dot phrase password Enter
text.secureTextEntry = YES;
Whether to correct the error
text.autocorrectionType = UITextAutocorrectionTypeNo; typedef enum {UITextAutocorrectionTypeDefault, 默认UITextAutocorrectionTypeNo, 不自动纠错UITextAutocorrectionTypeYes, 自动纠错} UITextAutocorrectionType;
Edit again and clear it
text.clearsOnBeginEditing = YES;
Content alignment
text.textAlignment = UITextAlignmentLeft;
Vertical alignment of content UITextField inherits from UIControl. There is a property in this class contentVerticalAlignment
text.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
When set to YES, the text will automatically shrink to fit the size of the text window. The default is to maintain the original size, and let Long text scrolling
textFied.adjustsFontSizeToFitWidth = YES;
Set the minimum font size for automatically reduced display
text.minimumFontSize = 20;
Set the keyboard style
text.keyboardType = UIKeyboardTypeNumberPad; typedef enum {UIKeyboardTypeDefault, 默认键盘,支持所有字符UIKeyboardTypeASCIICapable, 支持ASCII的默认键盘UIKeyboardTypeNumbersAndPunctuation, 标准电话键盘,支持+*#字符UIKeyboardTypeURL, URL键盘,支持.com按钮 只支持URL字符UIKeyboardTypeNumberPad, 数字键盘UIKeyboardTypePhonePad, 电话键盘UIKeyboardTypeNamePhonePad, 电话键盘,也支持输入人名UIKeyboardTypeEmailAddress, 用于输入电子 邮件地址的键盘UIKeyboardTypeDecimalPad, 数字键盘 有数字和小数点UIKeyboardTypeTwitter, 优化的键盘,方便输入@、#字符UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable,} UIKeyboardType;
Whether the first letter is capitalized
text.autocapitalizationType = UITextAutocapitalizationTypeNone; typedef enum {UITextAutocapitalizationTypeNone, 不自动大写UITextAutocapitalizationTypeWords, 单词首字母大写UITextAutocapitalizationTypeSentences, 句子的首字母大写UITextAutocapitalizationTypeAllCharacters, 所有字母都大写} UITextAutocapitalizationType;
What key does the return key become?
text.returnKeyType =UIReturnKeyDone; typedef enum { UIReturnKeyDefault, 默认 灰色按钮,标有 ReturnUIReturnKeyGo, 标有Go的蓝色按钮UIReturnKeyGoogle, 标有Google的蓝色按钮, 用语搜索UIReturnKeyJoin, 标有Join的蓝色按钮UIReturnKeyNext, 标有Next的蓝色按钮UIReturnKeyRoute, 标有Route的蓝色按钮UIReturnKeySearch, 标有Search的蓝色按钮UIReturnKeySend, 标有Send的蓝色按钮UIReturnKeyYahoo, 标有Yahoo的蓝色按钮UIReturnKeyYahoo, 标有Yahoo的蓝色按钮UIReturnKeyEmergencyCall, 紧急呼叫按钮} UIReturnKeyType;
Keyboard appearance
textView.keyboardAppearance=UIKeyboardAppearanceDefault; typedef enum {UIKeyboardAppearanceDefault, 默认外观,浅灰色UIKeyboardAppearanceAlert, 深灰 石墨色 } UIReturnKeyType;
Set the proxy to implement the protocol
text.delegate = self;
Add textfield to the view
[self.window addSubview:text];
The image added on the far right is similar to the following code on the left side
UIImageView *image=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"right.png"]]; text.rightView=image; text.rightViewMode = UITextFieldViewModeAlways;
The above is the detailed content of What does textfield mean?. For more information, please follow other related articles on the PHP Chinese website!