iOS rainbow colors array

3 nested for loops and 3 variables r, g, b, and add 0.25 each time the loop occurs.


Far simpler, use -[UIColor colorWithHue:saturation:brightness:alpha:], like so:

NSMutableArray *colors = [NSMutableArray array];

float INCREMENT = 0.05;
for (float hue = 0.0; hue < 1.0; hue += INCREMENT) {
    UIColor *color = [UIColor colorWithHue:hue
                                saturation:1.0
                                brightness:1.0
                                     alpha:1.0];
    [colors addObject:color];
}

This allows you to vary the hue (or color) without changing how bright the color is on the screen, which you're very likely not preserving right now. It's also far simpler to write, and far clearer to a later reader.