typedef enum {
/// #E57349
brand = 0,
/// #232934
primary,
/// #232934
contentPrimary,
/// #4F545D
contentSecondry,
/// #7B7E85
contentTertiary,
/// #A8ABB3, 原 contentDisable
contentQuaternary,
/// #FFFFFF
background1,
/// #F3F3F5
background2,
/// #F8F8FA
background3,
/// #EEEEEE
line,
/// #509FFA
tips,
/// #65CD81
safe,
/// #FFB400
warning,
/// #F53C32
error,
/// clear color
clear,
/// #000000
black,
/// #CACACA
contentSecondryForceLight,
/// #757575
contentTertiaryForceLight,
/// #FFFFFF
contentPrimaryForceLight,
/// #FF8559
mapColor1,
/// #4D587B
mapColor2,
/// #A8ABB3
contentDisable,
/// #F3F3F5
disable
} LColor_OCType;
typedef enum {
Disable, // 0.3
Mask, // 0.5,
Press,// 0.8,
Normal, // 1.0
} alpha;
@interface LColor_OC : NSObject
+(LColor_OC*)colorType:(LColor_OCType)type;
-(UIColor*)color;
-(UIColor*)color:(alpha)alpha;
@end
const NSString *ColorTypeStringMap[] = {
/// #E57349
[brand] = @"brand",
/// #232934
[primary] = @"primary",
/// #232934
[contentPrimary] = @"contentPrimary",
/// #4F545D
[contentSecondry] = @"contentSecondry",
/// #7B7E85
[contentTertiary] = @"contentTertiary",
/// #A8ABB3, 原 contentDisable
[contentQuaternary] = @"contentQuaternary",
/// #FFFFFF
[background1] = @"background1",
/// #F3F3F5
[background2] = @"background2",
/// #F8F8FA
[background3] = @"background3",
/// #E5E5E5
[line] = @"line",
/// #509FFA
[tips] = @"tips",
/// #65CD81
[safe] = @"safe",
/// #FFB400
[warning] = @"warning",
/// #F53C32
[error] = @"error",
/// clear color
[clear] = @"clear",
/// #000000
[black] = @"black",
/// #CACACA
[contentSecondryForceLight] = @"contentSecondryForceLight",
/// #757575
[contentTertiaryForceLight] = @"contentTertiaryForceLight",
/// #FFFFFF
[contentPrimaryForceLight] = @"contentPrimaryForceLight",
/// #FF8559
[mapColor1] = @"mapColor1",
/// #4D587B
[mapColor2] = @"mapColor2",
/// #A8ABB3
[contentDisable] = @"contentDisable",
/// #F3F3F5
[disable] = @"disable"
};
@interface LColor_OC ()
@property (nonatomic,assign) LColor_OCType colorType;//颜色分类
@end
@implementation LColor_OC
+(LColor_OC*)colorType:(LColor_OCType)type{
LColor_OC * ocColor = [[LColor_OC alloc]init];
ocColor.colorType = type;
return ocColor;
}
-(UIColor*)color{
if (self.colorType == clear) {
return [UIColor clearColor];
}
NSString * colorName = [self colorName];
NSBundle *coreBundle = [OCHelper lui_coreBundle];
UIColor * color = [UIColor colorNamed:colorName inBundle:coreBundle compatibleWithTraitCollection:nil];
NSString * error = [NSString stringWithFormat:@"%@ 颜色可能没有配置!!",[self colorName]];
NSAssert(color, error);
return color;
}
-(UIColor*)color:(alpha)alpha{
CGFloat _alpha;
switch (alpha) {
case Normal:
_alpha = 1.0;
break;
case Mask:
_alpha = 0.5;
break;
case Press:
_alpha = 0.8;
break;
case Disable:
_alpha = 0.3;
break;
default:
_alpha = 1.0;
break;
}
UIColor * color = [[self color]colorWithAlphaComponent:_alpha];
return color;
}
-(NSString*)colorName{
NSString * colorName = ColorTypeStringMap[self.colorType];
return colorName;
}
@end
Color
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- python python中的新知识点 cv.COLOR_BGR2YUV cv.COLOR_BGR2HSV cv....
- 摘自:https://blog.csdn.net/sinat_31213021/article/details/1...
- Create a color from RGBA values from 0 to 1.创建一个值在0~1之间的R...
- Photoshop Color Correction: Dark Color Cast 中文字幕 Photosho...