UITextfield

来源:互联网 发布:js上传多张图片 编辑:程序博客网 时间:2024/04/30 05:52
UITextField

设置大小
UITextField *textField =[ [UITextField alloc]initWithFrame:CGRectMake(x,y,w,h)];
初始化文字
textField.text = @"";
设置字体颜色
textField.textColor = [UIColor redColor];
设置字体系统大小
textField.font = [UIFont boldSystemSizeOfSize:1];
设置字体对其方式
textField.textAlignment = NSTextAlignmentCenter;
设置输入框风格
textField.borderStyle = UITextBorderStyleLine;
textField.borderStyle = UITextBorderStyleBzel;
textField.borderStyle = UITextBorderStyleRoundedRect;
设置输入框的提示文字
textField.placeholder = @"请输入账号";
设置在输入时时候删除之前的字体
textField.clearOnBeginEditing = YES;
把控件放在视图控件上(子视图放在父视图上)
[self.view addSubview:textField];
让此输入框失去焦点
-(void)touchBegan:(NSSet *)thouches withEvent:(UIEvent *)event{
[textField resignFirstResponder];
}