Skip to content

Instantly share code, notes, and snippets.

@haldun
Created November 2, 2013 10:33
Show Gist options
  • Save haldun/7277574 to your computer and use it in GitHub Desktop.
Save haldun/7277574 to your computer and use it in GitHub Desktop.
random color
- (UIColor *)randomColor
{
return [self randomColorWithAlpha:1.0f];
}
- (UIColor *)randomColorWithAlpha:(CGFloat)alpha
{
CGFloat hue = (arc4random() % 256 / 256.0 );
CGFloat saturation = (arc4random() % 128 / 256.0 ) + 0.5;
CGFloat brightness = (arc4random() % 128 / 256.0 ) + 0.5;
return [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:alpha];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment