UITextFiled
2015-11-10 09:31 xiangjune 阅读(170) 评论(0) 编辑 收藏 举报
- (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;
}