- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
field = [[UITextField alloc]initWithFrame:CGRectMake(100, 100, 200, 50)];
field.placeholder = @"please input some word...";
field.font = [UIFont systemFontOfSize:18];
field.textColor = [UIColor blackColor];
field.borderStyle = UITextBorderStyleRoundedRect;
field.textAlignment = NSTextAlignmentCenter;
field.backgroundColor = [UIColor grayColor];
// field.secureTextEntry = YES;
field.keyboardType = UIKeyboardTypeNumberPad;
field.delegate = self;
[self.view addSubview:field];
// 弹出键盘
[field becomeFirstResponder];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
// 关闭键盘
[field resignFirstResponder];
return YES;
}