UITextField, uitextfield multiple rows
// 1. Set the background
// Tf. backgroundColor = [[UIColor blueColor] colorWithAlphaComponent: 0.7];
// 2. Set the style of the input box
/*
UITextBorderStyleNone, default style, no style
UITextBorderStyleLine, rectangular line style
UITextBorderStyleBezel, blade line style
UITextBorderStyleRoundedRect rounded corner Style
*/
Tf. borderStyle = UITextBorderStyleRoundedRect;
// Obtain the image
UIImage * image = [UIImage imageNamed: @ "btn_bg"];
// Stretch the image by region
Image = [image resizableImageWithCapInsets: UIEdgeInsetsMake (image. size. height/2, image. size. width/2, image. size. height/2, image. size. width/2)];
// 3. Set the background image
Tf. background = [UIImage imageNamed: @ "btn_bg"];
// 4. Set the text color
Tf. textColor = [UIColor grayColor];
// 5. Set the font and size of the text
Tf. font = [UIFont systemFontOfSize: 20];
// 6. Set alignment
// Tf. textAlignment = NSTextAlignmentCenter;
// 7. Text adaptive input box width
Tf. adjustsFontSizeToFitWidth = YES;
// 8. Set the minimum text Adaptability
Tf. minimumFontSize = 5;
// 9. Set the image on the left of textField, as shown in the figure below.
UIImageView * leftImageV = [[UIImageView alloc] initWithFrame: CGRectMake (0, 0, 30, 25)];
LeftImageV. image = [UIImage imageNamed: @ "username_icon"];
Tf. leftView = leftImageV;
/*
UITextFieldViewModeNever, not displayed
UITextFieldViewModeWhileEditing, displayed when editing status
UITextFieldViewModeUnlessEditing, not the editing Status display
UITextFieldViewModeAlways always display
*/
Tf. leftViewMode = UITextFieldViewModeAlways;
// Set the picture on the right. The principle is as follows: Set the picture on the left.
// Tf. rightView
// Tf. rightViewMode
// 10. Set the placeholder, that is, the text in the input box at the beginning. When we enter the value, it will be gone.
// Tf. placeholder = @ "Enter the user name ";
// Modify the color and text size of the placeholder
Tf. attributedPlaceholder = [[NSAttributedString alloc] initWithString: @ "Enter the user name" attributes :@{ region: [UIFont systemFontOfSize: 15], Region: [UIColor blueColor]}];
// 11. The clear button on the right is displayed, as shown in the figure below.
/*
UITextFieldViewModeNever, not displayed
UITextFieldViewModeWhileEditing, displayed during editing
UITextFieldViewModeUnlessEditing, displayed when not edited
UITextFieldViewModeAlways always show
*/
Tf. clearButtonMode = UITextFieldViewModeWhileEditing
// 12. Security input, applicable to Password Input
Tf. secureTextEntry = NO;
// 13. It is automatically cleared when the input status is set.
Tf. clearsOnBeginEditing = YES;
// 14. Editing is not allowed. This method is rarely used.
// Tf. enabled = NO;
// 15. Set the keyboard Style
// Tf. keyboardType = UIKeyboardTypeNumberPad;
// 16. Set the style of the return button. There are many styles. Here we will not demonstrate them one by one. You can view them by yourself.
Tf. returnKeyType = UIReturnKeyJoin;
// 17. Whether to correct the error. For example, if you want to input "Hello" and press "Hollo", the system will automatically help you correct the error.
/*
UITextAutocorrectionTypeDefault,
UITextAutocorrectionTypeNo,
UITextAutocorrectionTypeYes,
*/
Tf. autocorrectionType = UITextAutocorrectionTypeYes;