Search code examples
iosobjective-cnsarrayiboutletcollection

How to modify color of label in IBOutletCollection


My question is - how do I modify any color like backgroundColor, textColor of each label in

IBOutletCollection(UILabel) NSArray *smallLabels 

I tried everything to access each element of the array using the index. In my case I have 10 labels, each label have its number from 1 to 10.

All I've done so far is connecting each label to the IBOutletCollection, but I have a clue that I have never initialized my array in code.

Thanks in advance.


Solution

  • Please try this

    for (UILabel *myLabel in self.smallLabels) 
    {
      myLabel. backgroundColor = [UIColor greenColor];
    }