用处:输入控件
-(void)viewDidLoad
{
[super viewDidLoad];
//设置大小
CGRect frame = CGRectMake(20,20,150,40);
//实例化UITextField
self.tf = [[UITextField alloc]initWithFrame:frame];
//提示信息(灰体)
self.tf.placeholder = @"type in password";
//边框样式
self.tf.borderStyle = UITextBorderStyleRoundedRect;
//对齐方式
self.tf.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
self.tf.textAlignment = NSTextAlignmentLeft;
//密码
self.tf.secureTextEntry = YES;
//编辑时的清除按钮
self.tf.clearButtonMode = UITextFieldViewModeWhileEditing;
[self.view addSubView:self.tf];
}
UITextField控件
时间: 2024-10-21 14:39:19