1、创建
UITextField *textField = [[UITextField alloc] init];
2、位置和大小
textField.frame = CGRectMake(100, 100, 200, 30);
3、背景颜色
textField.backgroundColor = [UIColor yellowColor];
4、提示语
textField.placeholder = @"这是提示词";
5、是否能编辑
textField.enabled = NO;
6、外形:倒角等
textField.layer.cornerRadius = 10;
textField.layer.borderWidth = 1.5;
textField.layer.borderColor = [[UIColor redColor] CGColor];
```
7、键盘类型
/*
UIKeyboardTypeDefault
UIKeyboardTypeASCIICapable
UIKeyboardTypeNumbersAndPunctuation
UIKeyboardTypeURL
UIKeyboardTypeNumberPad
UIKeyboardTypePhonePad
UIKeyboardTypeNamePhonePad
UIKeyboardTypeEmailAddress
UIKeyboardTypeDecimalPad
UIKeyboardTypeTwitter
UIKeyboardTypeWebSearch
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable
*/
textField.keyboardType = UIKeyboardTypePhonePad;
8、清除内容
/*
UITextFieldViewModeNever,
UITextFieldViewModeWhileEditing,
UITextFieldViewModeUnlessEditing,
UITextFieldViewModeAlways
*/
textField.clearButtonMode = UITextFieldViewModeAlways;
“`