@interface AppDelegate ()<UITextFieldDelegate>
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
_window.backgroundColor = [UIColor greenColor];
UITextField *textfiled =[[UITextField alloc]initWithFrame:CGRectMake(50, 50,200, 50)];
textfiled.placeholder = @"请输入:";
textfiled.backgroundColor = [UIColor purpleColor];
[_window addSubview:textfiled];
// 清除
textfiled.clearButtonMode=UITextFieldViewModeAlways;
// 安全
textfiled.secureTextEntry=YES;
// 键盘类型
textfiled.keyboardType = UIKeyboardTypeNamePhonePad;
// 设置输入框样式
textfiled.borderStyle=UITextBorderStyleRoundedRect;
// 设圆角
textfiled.layer.cornerRadius=10;
// 加边框宽度
textfiled.layer.borderWidth=1;
// 字体加粗
textfiled.font= [UIFont boldSystemFontOfSize:50];
// 键盘收回 签订协议
textfiled.delegate = self;
return YES;
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
[_window endEditing:YES];
}
//键盘 return 收回键盘
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}