Skip to content

Instantly share code, notes, and snippets.

@leilee
Last active June 6, 2017 07:01
Show Gist options
  • Select an option

  • Save leilee/db3292c0e877dde80899f3a87f72c330 to your computer and use it in GitHub Desktop.

Select an option

Save leilee/db3292c0e877dde80899f3a87f72c330 to your computer and use it in GitHub Desktop.
generate random UIColor
@interface UIColor (Random)
+ (instancetype)randomColor;
@end
@implementation UIColor (Random)
+ (instancetype)randomColor
{
CGFloat r = arc4random_uniform(255) / 255.0;
CGFloat g = arc4random_uniform(255) / 255.0;
CGFloat b = arc4random_uniform(255) / 255.0;
return [UIColor colorWithRed:r green:g blue:b alpha:1];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment