_helloField = [[UITextField alloc] initWithFrame:CGRectMake(70, 150, 140, 40)];
//样式,如果要用自定义图片背景的话要设成none
_helloField.borderStyle = UITextBorderStyleLine;
_helloField.placeholder = @"提醒用户";
_helloField.tag = 123;
//每次开始编辑的时候清除原有内容
_helloField.clearsOnBeginEditing = YES;
//开始编辑后,出现清除按钮
_helloField.clearButtonMode = UITextFieldViewModeWhileEditing;
//设置背景图片
//_helloField.background = [UIImage imageNamed:@"navigation"];
//设置为密码输入
//_helloField.secureTextEntry = YES;
//自定义右边小图标(自定义clear button)
UIView *rightview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
rightview.backgroundColor = [UIColor redColor];
_helloField.rightView = rightview;
_helloField.rightViewMode = UITextFieldViewModeWhileEditing;
//自定义系统键盘
/*
UIView *csView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
csView.backgroundColor = [UIColor blueColor];
_helloField.inputView = csView;
*/
//与系统键盘共存,在系统键盘上再加一块儿
UIView *csView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
csView.backgroundColor = [UIColor blueColor];
_helloField.inputAccessoryView = csView;
//键盘类型
//_helloField.keyboardType = UIKeyboardTypeNumberPad;
//返回键设置
_helloField.returnKeyType = UIReturnKeyDone;
//设置键盘大小写
_helloField.autocapitalizationType = UITextAutocapitalizationTypeNone;
[self.view addSubview:_helloField];