首页 > 代码库 > UITextField控件

UITextField控件

用处:输入控件

-(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];

}