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];
}
本文介绍如何使用 Objective-C 代码创建 UITextField,并设置了 UITextField 的位置、大小、文本对齐方式、字体及背景颜色。
1159

被折叠的 条评论
为什么被折叠?



