您的位置:首页 > 其它

基本控件

2016-02-23 14:55 211 查看
一、标签( 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 = @“
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  基本控件