+ (UIColor*)colorFromHex:(NSString*)hexString { // https://github.com/timd/UIColor-HexValues hexString = [hexString stringByReplacingOccurrencesOfString:@"#" withString:@""]; if ([hexString length] == 3) { hexString = [NSString stringWithFormat:@"%@%@%@%@%@%@", [hexString substringWithRange:NSMakeRange(0, 1)],[hexString substringWithRange:NSMakeRange(0, 1)], [hexString substringWithRange:NSMakeRange(1, 1)],[hexString substringWithRange:NSMakeRange(1, 1)], [hexString substringWithRange:NSMakeRange(2, 1)],[hexString substringWithRange:NSMakeRange(2, 1)]]; } if ([hexString length] != 6) { return nil; } // Brutal and not-very elegant test for non hex-numeric characters NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"[^a-fA-F|0-9]" options:0 error:NULL]; NSUInteger match = [regex numbe