UITextField
UITextField:文本输入框
// 创建一个textField
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(60, 40, 200, 30)];
textField.backgroundColor = [UIColor lightGrayColor]; // 通常不设置
textField.text = @"测试"; // 通常不设置
textField.placeholder = @"手机号/邮箱"; // 背景显示内容
textField.secureTextEntry = YES; // 密码模式
textField.returnKeyType = UIReturnKeyGo; // 键盘右下角 return 换成go
// 修改textField弹出来的视图,系统键盘(替换键盘 x y 宽 设置无用)
textField.inputView = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 100)] autorelease];
UIView *accessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
accessoryView.backgroundColor = [UIColor yellowColor]; // 透明色 clearColor
textField.inputAccessoryView = accessoryView; // 添加辅助视图 紧挨键盘在其上面
[accessoryView release];
textField.borderStyle = UITextBorderStyleRoundedRect; // 边框
textField.clearButtonMode = UITextFieldViewModeAlways; // 输入框右侧删除按钮
// 给textField添加左视图
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];
label.text = @"用户名";
textField.leftView = label;
textField.leftViewMode = UITextFieldViewModeAlways; // 添加左视图
[label release];
// 自动首字母大写
textField.autocapitalizationType = UITextAutocapitalizationTypeNone; // 关上
// 自动修正功能
textField.autocorrectionType = UITextAutocorrectionTypeNo; // 关上

浙公网安备 33010602011771号