Random Colors on iOS
A quick tip that I have to look up every time I use it. To generate nice random colors, use the HSV representation. Take random values for hue, and fixed numbers for saturation and value. This gives colors that work together, without looking too random.
srand48(time(0));
[[UIColor colorWithHue:drand48() saturation:0.5
brightness:0.95 alpha:0.5] setFill];
Remember to use setStroke if you need the outline of the shape. This article has more information, including better spaced colors. Thanks to NSHipster for the random number methods.