您的当前位置:首页正文

WHAttachment全局变量的定义

来源:要发发知识网

WHAttachment.h文件

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

extern NSString *iOSModel;
extern NSString *KOSVersion;
extern NSString *KApplicationName;
extern NSString *KApplicationVersion;
extern CGFloat KWidth;
extern CGFloat KHeight;

extern UIColor *KBlackColor;
extern UIColor *KGrayColor;
extern UIColor *KWhiteColor;
extern UIColor *KRedColor;
extern UIColor *KBlueColor;
extern UIColor *KClearColor;
extern UIColor *KYelowColor;
extern UIColor *KOrangeColor;
extern UIColor *KLightGrayColor;
extern UIColor *KDrakGrayColor;
extern UIColor *KGreenColor;

extern UIColor *KTitleColorBlack;
extern UIColor *KTitleColorGray;
extern UIColor *KTitleColorYellow;
extern UIColor *KTitleColorGreen;

extern UIColor *KMainViewColor;
extern UIColor *KNaviViewColor;
extern UIColor *KOpenViewColor;
extern UIColor *KToolViewColor;
extern UIColor *KCellViewColor;
extern UIColor *KBackViewColor;
extern UIColor *KLayerBorderColor;
extern UIColor *KDisabledColor;
extern UIColor *KLightMainViewColor;

extern UIColor *KTableHeaderColor;
extern CGFloat KTableHeaderHeight;
extern UIColor *KTableFooterColor;
extern CGFloat KTableFooterHeight;
extern UIColor *KCellSeparatorColor;
extern CGFloat KCellSeparatorWidth;

extern UIFont *KTextFontMax;
extern UIFont *KTextFontMid;
extern UIFont *KTextFontMin;
static inline UIColor *WHRGBColor(CGFloat red, CGFloat green, CGFloat blue){
    return [UIColor colorWithRed:red/255.0 green:green/255.0 blue:blue/255.0 alpha:1.0];
}

static inline UIColor *WHRGBAColor(CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha){
    return [UIColor colorWithRed:red/255.0 green:green/255.0 blue:blue/255.0 alpha:alpha];
}

static inline UIColor *WHRGBColorWithPlaceholder(NSString *rgbColor, UIColor *placeholder){
    NSArray *RGB = [rgbColor componentsSeparatedByString:@","];
    if(RGB.count == 3){
        return WHRGBColor([[RGB objectAtIndex:0] floatValue], [[RGB objectAtIndex:1] floatValue], [[RGB objectAtIndex:2] floatValue]);
    }
    return placeholder;
}

static inline UIColor *WHRGBAColorWithPlaceholder(NSString *rgbaColor, UIColor *placeholder){
    NSArray *RGBA = [rgbaColor componentsSeparatedByString:@","];
    if(RGBA.count == 4){
        return WHRGBAColor([[RGBA objectAtIndex:0] floatValue], [[RGBA objectAtIndex:1] floatValue], [[RGBA objectAtIndex:2] floatValue], [[RGBA objectAtIndex:3] floatValue]);
    }
    return placeholder;
}

static inline UIFont *WHFont(CGFloat fontSize){
    return [UIFont systemFontOfSize:fontSize];
}

static inline UIFont *WHBoldFont(CGFloat fontSize){
    return [UIFont boldSystemFontOfSize:fontSize];
}

static inline UIFont *WHFontName(NSString *fontName, CGFloat fontSize){
    return [UIFont fontWithName:fontName size:fontSize];
}
@interface WHAttachment : NSObject
@end

WHAttachment.m文件

#import "WHAttachment.h"

NSString *iOSModel;
NSString *KOSVersion;
NSString *KApplicationName;
NSString *KApplicationVersion;
CGFloat KWidth;
CGFloat KHeight;

UIColor *KBlackColor;
UIColor *KGrayColor;
UIColor *KWhiteColor;
UIColor *KRedColor;
UIColor *KBlueColor;
UIColor *KClearColor;
UIColor *KYelowColor;
UIColor *KOrangeColor;
UIColor *KLightGrayColor;
UIColor *KDrakGrayColor;
UIColor *KGreenColor;

UIColor *KTitleColorBlack;
UIColor *KTitleColorGray;
UIColor *KTitleColorYellow;
UIColor *KTitleColorGreen;

UIColor *KMainViewColor;
UIColor *KNaviViewColor;
UIColor *KOpenViewColor;
UIColor *KToolViewColor;
UIColor *KCellViewColor;
UIColor *KBackViewColor;
UIColor *KLayerBorderColor;
UIColor *KDisabledColor;
UIColor *KLightMainViewColor;

UIColor *KTableHeaderColor;
CGFloat KTableHeaderHeight;
UIColor *KTableFooterColor;
CGFloat KTableFooterHeight;
UIColor *KCellSeparatorColor;
CGFloat KCellSeparatorWidth;

UIFont *KTextFontMax;
UIFont *KTextFontMid;
UIFont *KTextFontMin;
@implementation WHAttachment
+ (void)load{
    iOSModel = [[UIDevice currentDevice].model retain];
    KOSVersion = [[UIDevice currentDevice].systemVersion retain];
    KApplicationName = [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"] retain];
    KApplicationVersion = [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] retain];
    KWidth = [[UIScreen mainScreen] bounds].size.width;
    KHeight = [[UIScreen mainScreen] bounds].size.height;
    
    KBlackColor = [[UIColor blackColor] retain];
    KGrayColor = [[UIColor grayColor] retain];
    KWhiteColor = [[UIColor whiteColor] retain];
    KRedColor = [[UIColor redColor] retain];
    KBlueColor = [[UIColor blueColor] retain];
    KClearColor = [[UIColor clearColor] retain];
    KYelowColor = [[UIColor yellowColor] retain];
    KOrangeColor = [[UIColor orangeColor] retain];
    KLightGrayColor = [[UIColor lightGrayColor] retain];
    KDrakGrayColor = [[UIColor darkGrayColor] retain];
    KGreenColor = [[UIColor greenColor] retain];
    
    KTitleColorBlack =  [WHRGBColor(38, 38, 38) retain];
    KTitleColorGray = [WHRGBColor(108, 108, 108) retain];
    KTitleColorYellow = [WHRGBColor(255, 102, 0) retain];
    KTitleColorGreen = [WHRGBColor(83, 215, 105) retain];
    
    KMainViewColor =  [WHRGBColor( 24, 178, 237) retain];
    KNaviViewColor =  [WHRGBColor( 24, 178, 237) retain];
    KOpenViewColor =  [WHRGBColor(239, 239, 244) retain];
    KToolViewColor  =  [WHRGBColor(255, 255, 255) retain];
    KCellViewColor  =  [WHRGBColor(255, 255, 255) retain];
    KBackViewColor  =  [WHRGBColor(100, 100, 100) retain];
    KLayerBorderColor = [WHRGBColor(222, 222, 222) retain];
    KDisabledColor  =   [WHRGBColor(210, 220, 229) retain];
    KLightMainViewColor = [WHRGBColor(217, 237, 247) retain];
    
    KTableHeaderColor = [WHRGBColor(239, 239, 244) retain];;
    KTableHeaderHeight = 20;
    KTableFooterColor = [WHRGBColor(239, 239, 244) retain];;
    KTableFooterHeight = 20;
    KCellSeparatorColor = [WHRGBColor(209, 209, 209) retain];
    KCellSeparatorWidth = (1.0/[[UIScreen mainScreen] scale]);
    
    KTextFontMax = [WHFont(17) retain];
    KTextFontMid = [WHFont(14) retain];
    KTextFontMin = [WHFont(12) retain];
}
@end