Created
January 13, 2012 03:07
-
-
Save mtsd/1604373 to your computer and use it in GitHub Desktop.
ランダムなUIColorを取得
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
| 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