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 }
相關文章
相關標籤/搜索