iOS create UILabels dynamically

后端 未结 6 776
甜味超标
甜味超标 2020-12-31 05:54

Sometimes I want my view to contain 5 UILabels, sometimes 3 and sometimes n.

The number of UILabels depends on data that\'s fetched fro

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-31 06:33

     UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(125, 12,170,20)];
                lbl.text=@"IOS";
                lbl.textAlignment = NSTextAlignmentCenter;
                lbl.textColor = [UIColor whiteColor];
                lbl.font = [UIFont fontWithName:@"AlNile" size:10.0];
                lbl.backgroundColor=[[UIColor redColor]colorWithAlphaComponent:0.5f];
                lbl.layer.borderColor=[UIColor blackColor].CGColor;
                lbl.layer.borderWidth=1.0f;
                lbl.layer.cornerRadius = 6.0f;
                [self.view addSubview:lbl];
    

提交回复
热议问题