1、UITextField:
#pragma mark 通过代码创建UITextField
-(void)makeUITextFieldWithSourcecode{
UITextField *textField =[[UITextField alloc]initWithFrame:CGRectMake(100, 100, 200, 30)];
[textField setTextAlignment:NSTextAlignmentCenter];
textField.font = [UIFont systemFontOfSize:20];
[textField setBackgroundColor:[UIColor redColor]]; //注意要给UITextField设置background(图片或者color)否则在界面上会看不到
[self.view addSubview:textField];
}
#pragma mark 通过代码创建UITextField
-(void)makeUITextFieldWithSourcecode{
UITextField *textField =[[UITextField alloc]initWithFrame:CGRectMake(100, 100, 200, 30)];
[textField setTextAlignment:NSTextAlignmentCenter];
textField.font = [UIFont systemFontOfSize:20];
[textField setBackgroundColor:[UIColor redColor]]; //注意要给UITextField设置background(图片或者color)否则在界面上会看不到
[self.view addSubview:textField];
}