您可以使用这种类型的代码
int lblY = 10; // As per your requirement
int viewBHT = 50; // As per your requirement
UILabel *lbl;
NSMutableArray *arrLbl = [[NSMutableArray alloc] initWithObjects:@"1",@"1",@"1",@"1",@"1",@"1", nil];
UIView *viewB = [[UIView alloc] init];
[viewB setFrame:CGRectMake(0, viewA.frame.origin.y, self.view.frame.size.width, viewBHT)];
[viewB setBackgroundColor:[UIColor darkGrayColor]];
[self.view addSubview:viewB];
for (int i = 0; i < arrLbl.count; i++)
{
lbl = [[UILabel alloc] initWithFrame:CGRectMake(10, lblY , viewB.frame.size.width - 20, 30)];
[lbl setText:[NSString stringWithFormat:@"Hello %d",i]];
[lbl setBackgroundColor:[UIColor lightGrayColor]];
[viewB addSubview:lbl];
lblY = lblY + lbl.frame.size.height + 10;
}
viewBHT = lbl.frame.size.height + lbl.frame.origin.y + 10;
[viewB setFrame:CGRectMake(0, 80, self.view.frame.size.width, viewBHT)];
UIView *viewC = [[UIView alloc] init];
[viewC setFrame:CGRectMake(0, viewB.frame.origin.y + viewB.frame.size.height + 10, self.view.frame.size.width, 50)];
[viewC setBackgroundColor:[UIColor blueColor]];
[self.view addSubview:viewC];
希望能帮到你..!!:)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句