UITextField
创建输入框确定输入框的位置和大小
UITextField *textFiled = [[UITextField alloc] initWithFrame:CGRectMake(100, 100, 200, 40)];
输入框的背景颜色
textFiled.backgroundColor = [UIColor redColor];
输入框的边框宽 圆角 边框颜色
textFiled.layer.borderWidth = 1
textFiled.layer.cornerRadius = 10
textFiled.layer.borderColor = [UIColor blackColor].CGColor
输入框内文本的颜色及对齐方式
textFiled.textColor = [UIColor yellowColor]
textFiled.textAlignment = NSTextAlignmentCenter
占位文本 文本框内字体的大小
textFiled.placeholder = @"hey"
textFiled.font = [UIFont fontWithName:@"" size:20]
输入需要保密的文件时可以将字符设置成圆点
textFiled.secureTextEntry = YES;
设置不同类型的键盘
textFiled.keyboardType = UIKeyboardTypeNumberPad;
改变return的样式 这里指键盘的return按钮可设置成Done 等按钮
textFiled.returnKeyType = UIReturnKeySearch;
输入框中的清除按钮(就是输入框中的圆按钮) 及样式设置
textFiled.clearsOnBeginEditing = YES
textFiled.clearButtonMode = UITextFieldViewModeAlways
弹出自定义的视图
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100,200 , 200, 200)];
view.backgroundColor = [UIColor redColor];
textFiled.inputView = view;
textFiled.inputAccessoryView = view;
键盘的回收需要签订协议才能在方法中实现
@interface AppDelegate ()<UITextFieldDelegate>
textFiled.delegate = self;
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
NSLog(@"测试return按钮");
[textField resignFirstResponder];
return YES;