Last active
June 6, 2017 07:01
-
-
Save leilee/db3292c0e877dde80899f3a87f72c330 to your computer and use it in GitHub Desktop.
generate random 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
| @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