Created
November 2, 2013 10:33
-
-
Save haldun/7277574 to your computer and use it in GitHub Desktop.
random color
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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