Last active
December 20, 2015 15:09
-
-
Save troyharris/6152519 to your computer and use it in GitHub Desktop.
Get a random FlatUIColor in Objective-C using Grouper/FlatUIKit
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
// Requires UIColor+FlatUI.h from Grouper/FlatUIKit | |
static inline CGFloat skRandf() { | |
return rand() / (CGFloat) RAND_MAX; | |
} | |
static inline CGFloat skRand(CGFloat low, CGFloat high) { | |
return skRandf() * (high - low) + low; | |
} | |
-(UIColor *)getRandomColor { | |
//Not all of the FlatUI Colors, but a lot of them. You get the idea | |
NSArray *colorArr = @[[UIColor emerlandColor], [UIColor turquoiseColor], [UIColor carrotColor], [UIColor midnightBlueColor], [UIColor pomegranateColor], [UIColor orangeColor], [UIColor greenSeaColor], [UIColor peterRiverColor], [UIColor belizeHoleColor], [UIColor nephritisColor], [UIColor wisteriaColor], [UIColor amethystColor], [UIColor asbestosColor], [UIColor concreteColor], [UIColor wetAsphaltColor], [UIColor alizarinColor], [UIColor sunflowerColor], [UIColor pumpkinColor]]; | |
return (UIColor *)[colorArr objectAtIndex:skRand(0, (colorArr.count - 1))]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment