Skip to content

Instantly share code, notes, and snippets.

@ejknapp
Created February 14, 2013 21:05
Show Gist options
  • Save ejknapp/4956396 to your computer and use it in GitHub Desktop.
Save ejknapp/4956396 to your computer and use it in GitHub Desktop.
An Objective-C method to create a random color.
- (UIColor *)randomColor
{
CGFloat red = ((arc4random() % 100) / 100.0);
CGFloat green = ((arc4random() % 100) / 100.0);
CGFloat blue = ((arc4random() % 100) / 100.0);
return [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment