Skip to content

Instantly share code, notes, and snippets.

@mtsd
Created January 13, 2012 03:07
Show Gist options
  • Select an option

  • Save mtsd/1604373 to your computer and use it in GitHub Desktop.

Select an option

Save mtsd/1604373 to your computer and use it in GitHub Desktop.
ランダムなUIColorを取得
static UIColor * randomColorWithRGB() {
srand(time(NULL));
int rgb = random() % 3;
int code = random() % 10;
UIColor *color;
switch (rgb) {
case 0:
color = [UIColor colorWithRed:0.1 * code green:1.0 blue:1.0 alpha:1.0];
break;
case 1:
color = [UIColor colorWithRed:1.0 green:0.1 * code blue:1.0 alpha:1.0];
break;
default:
color = [UIColor colorWithRed:1.0 green:1.0 blue:0.1 * code alpha:1.0];
break;
}
return color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment