UITextField

来源:互联网 发布:软件项目个人总结 编辑:程序博客网 时间:2024/06/16 11:23

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;
“`

0 0
原创粉丝点击