iOS开发---UILabel

 1 -(void)creatUI{
 2     //创建一个UILabel
 3     UILabel* label = [[UILabel alloc] init];
 4     
 5     label.text = @"Hello world";
 6     
 7     label.frame = CGRectMake(100, 200, 160, 40);
 8     
 9     label.backgroundColor = [UIColor grayColor];
10     
11     label.textColor = [UIColor redColor];
12     
13     
14     
15     label.textAlignment = NSTextAlignmentCenter;
16     
17     label.font =  [UIFont systemFontOfSize:12];
18     
19 
20     //label 的高级属性
21     label.shadowColor = [UIColor blueColor];
22     
23     label.shadowOffset = CGSizeMake(5, 5);
24 
25     
26     
27     //当行数设置为0时,iOS自动计算行数。
28     label.numberOfLines = 0;
29     
30     [self.view addSubview:label];
31 
32 }
33 
34         
35          
36          
37          
38 - (void)viewDidLoad {
39     [super viewDidLoad];
40     
41     //调用creatUI函数
42     [self creatUI];
43 
44 }
原文地址:https://www.cnblogs.com/vector11248/p/7567066.html