UITextField
初始化
UITextField *textFiled = [[UITextField alloc] initWithFrame:CGRectMake(100, 100, 200, 50)]
textFiled.backgroundColor = [UIColor whiteColor]
textFiled.text = @"曹青衣"
对齐方式
textFiled.textAlignment = NSTextAlignmentCenter;
textFiled.textColor = [UIColor redColor];
设置字体大小
textFiled.font = [UIFont systemFontOfSize:22];
占位字
textFiled.placeholder = @"请输入xxx"

是否允许编辑
textFiled.enabled = NO;
是否开始输入的时候清空输入框内容
textFiled.clearsOnBeginEditing = YES;
是否文字以圆点格式显示(密文输入)
textFiled.secureTextEntry = YES;
设置弹出键盘的类型(枚举值)
textFiled.keyboardType = UIKeyboardTypeDefault;
键盘右下角return按钮的类型
textFiled.returnKeyType = UIReturnKeyNext;
自定义键盘(默认是键盘)
UIView *inputView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 300)];
inputView.backgroundColor = [UIColor greenColor];
textFiled.inputView = inputView;
[inputView release];
输入视图上方的辅助视图(默认为nil)
UIView *accessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
accessoryView.backgroundColor = [UIColor redColor];
textFiled.inputAccessoryView = accessoryView;
accessoryView release];

边框样式(枚举值)
textFiled.borderStyle = UITextBorderStyleRoundedRect;
清除按钮模式(默认永不出现)
textFiled.clearButtonMode = UITextFieldViewModeWhileEditing;
输入框左视图 (宽高有影响)
UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
leftView.backgroundColor = [UIColor blackColor];
textFiled.leftView = leftView;
[leftView release];
左视图的显示模式
textFiled.leftViewMode = UITextFieldViewModeWhileEditing;
输入框右视图及显示方式
UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
rightView.backgroundColor = [UIColor grayColor];
textFiled.rightView = rightView;
[rightView release];
textFiled.rightViewMode = UITextFieldViewModeWhileEditing;

设置代理
textField.delegate = self;
[self.window addSubview:textFiled];
[textFiled release];
键盘回收
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}