Home > Java > javaTutorial > body text

What does textfield mean?

anonymity
Release: 2020-10-12 14:45:40
Original
16190 people have browsed it

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.

What does textfield mean?

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)];
Copy after login

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;
Copy after login

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];
Copy after login

Set background

text.background = [UIImage imageNamed:@"dd.png"];
Copy after login

Set background

text.disabledBackground = [UIImage imageNamed:@"cc.png"];
Copy after login

When the input box has no content, the watermark prompt content is password

text.placeholder = @"password";
Copy after login

Set the font style and size of the input box content

text.font = [UIFont fontWithName:@"Arial" size:20.0f];
Copy after login

Set the font color

text.textColor = [UIColor redColor];
Copy after login

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;
Copy after login

The text that exists at the beginning of the input box

text.text = @"一开始就在输入框的文字";
Copy after login

Every time a character is entered, it becomes a dot phrase password Enter

text.secureTextEntry = YES;
Copy after login

Whether to correct the error

text.autocorrectionType = UITextAutocorrectionTypeNo;
typedef enum {UITextAutocorrectionTypeDefault, 
默认UITextAutocorrectionTypeNo, 
不自动纠错UITextAutocorrectionTypeYes, 
自动纠错} UITextAutocorrectionType;
Copy after login

Edit again and clear it

text.clearsOnBeginEditing = YES;
Copy after login

Content alignment

text.textAlignment = UITextAlignmentLeft;
Copy after login

Vertical alignment of content UITextField inherits from UIControl. There is a property in this class contentVerticalAlignment

text.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
Copy after login

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;
Copy after login

Set the minimum font size for automatically reduced display

text.minimumFontSize = 20;
Copy after login

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;
Copy after login

Whether the first letter is capitalized

text.autocapitalizationType = UITextAutocapitalizationTypeNone;
typedef enum {UITextAutocapitalizationTypeNone, 
不自动大写UITextAutocapitalizationTypeWords, 
单词首字母大写UITextAutocapitalizationTypeSentences, 
句子的首字母大写UITextAutocapitalizationTypeAllCharacters, 
所有字母都大写} UITextAutocapitalizationType;
Copy after login

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;
Copy after login

Keyboard appearance

textView.keyboardAppearance=UIKeyboardAppearanceDefault;
typedef enum 
{UIKeyboardAppearanceDefault, 
默认外观,浅灰色UIKeyboardAppearanceAlert, 深灰 石墨色
} UIReturnKeyType;
Copy after login

Set the proxy to implement the protocol

text.delegate = self;
Copy after login

Add textfield to the view

[self.window addSubview:text];
Copy after login

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;
Copy after login

The above is the detailed content of What does textfield mean?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!