+ (UIColor *)colorFromHexString:(NSString *)text
{
unsigned int colors[4] = {0,0,0,255};
if([text length]==6){
for (unsigned int i=0; i<3; i++) {
[[NSScanner scannerWithString:[text substringWithRange:NSMakeRange(2*i, 2)]] scanHexInt:&colors[i]];
}
}else if([text length]==8){
for (unsigned int i=0; i<4; i++) {
[[NSScanner scannerWithString:[text substringWithRange:NSMakeRange(2*i, 2)]] scanHexInt:&colors[i]];
}
}else{
return nil;
}
return [UIColor colorWithRed:(CGFloat)colors[0]/255.0
green:(CGFloat)colors[1]/255.0
blue:(CGFloat)colors[2]/255.0
alpha:(CGFloat)colors[3]/255.0];
}