基本控件
2016-02-23 14:55
267 查看
一、标签( UILabel)
1.创建标签
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, self.window.frame.size.width, 40)];
label.backgroundColor = [UIColor blackColor];
2.设置文字
label.text = @“男神最帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅";
3.设置字体颜色
label.textColor = [UIColor yellowColor];
4.设置字体以及大小
label.font = [UIFont systemFontOfSize:40];
5.文本的对齐方式
label.textAlignment = NSTextAlignmentCenter;
6.设置行数
label.numberOfLines = 2;
7.断行模式
label.lineBreakMode = NSLineBreakByClipping;
8.阴影颜色
label.shadowColor = [UIColor redColor];
9.设置阴影大小
label.shadowOffset = CGSizeMake(1, 2);
10.设置tag值
label.tag = 1001;
[self.window addSubview:label];
二、文本输入框(UITextField)
1.创建文本输入框
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 70, self.window.frame.size.width, 20)];
textField.backgroundColor = [UIColor yellowColor];
2.设置边框风格
textField.borderStyle = UITextBorderStyleLine;
3.设置占位符
textField.placeholder = @“
1.创建标签
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, self.window.frame.size.width, 40)];
label.backgroundColor = [UIColor blackColor];
2.设置文字
label.text = @“男神最帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅帅";
3.设置字体颜色
label.textColor = [UIColor yellowColor];
4.设置字体以及大小
label.font = [UIFont systemFontOfSize:40];
5.文本的对齐方式
label.textAlignment = NSTextAlignmentCenter;
6.设置行数
label.numberOfLines = 2;
7.断行模式
label.lineBreakMode = NSLineBreakByClipping;
8.阴影颜色
label.shadowColor = [UIColor redColor];
9.设置阴影大小
label.shadowOffset = CGSizeMake(1, 2);
10.设置tag值
label.tag = 1001;
[self.window addSubview:label];
二、文本输入框(UITextField)
1.创建文本输入框
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 70, self.window.frame.size.width, 20)];
textField.backgroundColor = [UIColor yellowColor];
2.设置边框风格
textField.borderStyle = UITextBorderStyleLine;
3.设置占位符
textField.placeholder = @“
相关文章推荐
- android基本控件ToggleButton&Switch使用指南
- 01 - 基本控件:文本域类控件(TextView、EditText、AutoCompleteTextView)
- 02 - 基本控件:按钮控件(Button、ImageButton、ToggleButton)
- 06 - 基本控件:Spinner下拉框
- 08 - 基本控件:GridView表格视图
- 11 - 布局Layout:LinearLayout线性布局
- Android 基础教程--TextView控件
- Android 基础教程--TextView控件
- Android 基础教程--TextView控件
- Android 基础教程--TextView控件
- Android 基础教程--TextView控件
- Android 基础教程--TextView控件
- Android 基础教程--TextView控件
- Android 基础教程--TextView控件
- Android 基础教程--TextView控件
- iOS-UI-基本控件之UIButton
- iOS-UI-基本控件之UILabel
- iOS-UI-基本控件之UIView
- iOS-UI-基本控件之继承关系
- iOS-UI-基本控件之UITextField