If you are loading the UILabels
from XIB, you can use IBOutletCollection
.
Declare property:
@property (nonatomic, strong) IBOutletCollection(UILabel) NSArray *labels;
Now you can link multiple labels in XIB to this property. Then in -viewDidLoad
(after loading the XIB), your array is populated and you just use simple for-in
:
for (UILabel *label in self.labels) {
label.backgroundColor = ...
}