#import #import "LSGColor.h" @implementation LSGColor + (UIColor *)colorWithHexValue:(NSInteger)color alpha:(CGFloat)alpha { return [UIColor colorWithRed:((float) ((color & 0xff0000) >> 16)) / 255.0 green:((float) ((color & 0x00ff00) >> 8)) / 255.0 blue:((float) (color & 0x0000ff)) / 255.0 alpha:alpha]; } + (UIColor *)colorWithHexString:(NSString *)stringToConvert { //去掉前后空格换行符 NSString *cString = [[stringToConvert stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString]; if ([cString hasPrefix:@"0X"]) cString = [cString substringFromIndex:2]; else if ([cString hasPrefix:@"#"]) cString = [cString substringFromIndex:1]; if ([cString length] != 6) return nil; // Separate into r, g, b substrings NSRange range; range.location = 0; range.length = 2; NSString *rString = [cString substringWithRange:range]; range.location = 2; NSString *gString = [cString substringWithRange:range]; range.location = 4; NSString *bString = [cString substringWithRange:range]; unsigned int r, g, b; [[NSScanner scannerWithString:rString] scanHexInt:&r]; [[NSScanner scannerWithString:gString] scanHexInt:&g]; [[NSScanner scannerWithString:bString] scanHexInt:&b]; return [UIColor colorWithRed:r / 255.0 green:g / 255.0 blue:b / 255.0 alpha:1.0]; } + (UIColor *)backgroudColor { return [UIColor whiteColor]; //[UIColor whiteColor]; } + (UIColor *)textColor { return [self colorWithHexValue:0x3E3E3E alpha:1.0]; } + (UIColor *)lightTextColor { return [self colorWithHexValue:0x7E7E7E alpha:1.0]; } + (UIColor *)redColor { return [self colorWithHexValue:0xD11301 alpha:1.0]; } + (UIColor *)borderColor { return [self colorWithHexValue:0xeeeeee alpha:1.0]; } @end