i am using one for loop for creating labels those are having text stored in nsarray.I want to display 1st labeltext color red and 2nd labeltext white and 3rd red ,4th white,5th red and 6th white ……….etc for all the labels that are stored in an array how to do this.help me on that ..can anyone shathanks in advance
Share
If you want to alternate between two colors the simplest thing is to use the modulo operator (%) to figure out if you are on an even or odd label index.
Here is one way of doing this:
You can also use this technique to alternate between more than two different colors, but then I would suggest that you put the colors into an array of their own and index that array using (labelIndex % numColors) or something similar.