【发布时间】:2015-10-29 20:25:16
【问题描述】:
我有这个代码。我想让它更紧凑。是否可以添加类似控件的组?
UILabel *controlFreeName = [[UILabel alloc] init];
controlFreeName.frame = CGRectMake(40.0f, 70.0f, 120.0f, 50.0f);
controlFreeName.text = @"Free";
UILabel *controlNoFreeName = [[UILabel alloc] init];
controlNoFreeName.frame = CGRectMake(40.0f, 110.0f, 120.0f, 50.0f);
controlNoFreeName.text = @"No free";
UILabel *controlEquipmentName = [[UILabel alloc] init];
controlEquipmentName.frame = CGRectMake(40.0f, 150.0f, 120.0f, 50.0f);
controlEquipmentName.text = @"Equipment";
UILabel *controlTypeName = [[UILabel alloc] init];
controlTypeName.frame = CGRectMake(40.0f, 190.0f, 180.0f, 50.0f);
controlTypeName.text = @"Type";
【问题讨论】:
-
你可以使用一个 for 循环和一个包含所有“文本”的 NSArray。
标签: ios objective-c ios7 ios8 controls