美文网首页
一些常用的宏定义

一些常用的宏定义

作者: CHADHEA | 来源:发表于2017-03-10 10:47 被阅读0次

    #define kNavHeight 64

    #define kTabBarHeight 49

    #define kSCREEN [UIScreen mainScreen].bounds

    #define kSCREEN_WIDTH [UIScreen mainScreen].bounds.size.width

    #define kSCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height

    #define kSCREEN_MAX_LENGTH (MAX(kSCREEN_WIDTH,kSCREEN_HEIGHT))

    #define kSCREEN_MIN_LENGTH (MIN(kSCREEN_WIDTH,kSCREEN_HEIGHT))

    #define kViewWidth(VIEW) VIEW.bounds.size.width

    #define kViewHeight(VIEW) VIEW.bounds.size.height

    #define kViewOriginX(VIEW) VIEW.frame.origin.x

    #define kViewOriginY(VIEW) VIEW.frame.origin.y

    #define kViewCenterX(VIEW) VIEW.center.x

    #define kViewCenterY(VIEW) VIEW.center.y

    #define kImageWidth(named) [UIImage imageNamed:named].size.width

    #define kImageHeight(named) [UIImage imageNamed:named].size.height

    #define kImageWithName(NAME) [UIImage imageNamed:NAME]

    #define kImageWithModelName(NAME) [[UIImage imageNamed:NAME]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]

    #define kImageWithData(DATA) [UIImage imageWithData:DATA]

    #define kPopViewController(viewController) [viewController.navigationController popViewControllerAnimated:YES]

    #define kNavFrame CGRectMake(0, 0, kSCREEN_WIDTH, kNavHeight)

    #define kTabBarFrame CGRectMake(0,kSCREEN_HEIGHT - kTabBarHeight, kSCREEN_WIDTH, kTabBarHeight)

    #define kScreenFrame CGRectMake(0, 0, kSCREEN_WIDTH, kSCREEN_HEIGHT)

    #define kViewFrameWithHeight(HEIGHT) CGRectMake(0, 0, kSCREEN_WIDTH, HEIGHT)

    #define kViewFrameWithWidth(WIDTH) CGRectMake(0, 0,WIDTH, kSCREEN_HEIGHT)

    #define kUSER_DEFAULT [NSUserDefaults standardUserDefaults]

    #define kFontWithSize(SIZE) [UIFont systemFontOfSize:SIZE]

    #define kFontWithBoldSize(SIZE) [UIFont boldSystemFontOfSize:SIZE]

    #define kFontWithSize_Weight(SIZE,WEIGHT) [UIFont systemFontOfSize:SIZE weight:WEIGHT]

    #define kBlueColor [UIColor blueColor]

    #define kCyanColor [UIColor cyanColor]

    #define kWhiteColor [UIColor whiteColor]

    #define kYellowColor [UIColor yellowColor]

    #define kMagentaColor [UIColor magentaColor]

    #define kPurpleColor [UIColor purpleColor]

    #define kRedColor [UIColor redColor]

    #define kBrownColor [UIColor brownColor]

    #define kBlackColor [UIColor blackColor]

    #define kOrangeColor [UIColor orangeColor]

    #define kGreenColor [UIColor greenColor]

    #define kGrayColor [UIColor grayColor]

    #define kClearColor [UIColor clearColor]

    #define kColorWithRGB_A(RED,GREEN,BLUE,ALPHA) [UIColor colorWithRed:RED green:GREEN blue:BLUE alpha:ALPHA]

    #define kColorWithRGB(RED,GREEN,BLUE,ALPHA) [UIColor colorWithRed:RED green:GREEN blue:BLUE alpha:1.0f]

    #define kColorWithW_A(WHITE,ALPHA) [UIColor colorWithWhite:WHITE alpha:ALPHA]

    #define kColorWithWHITE(WHITE) [UIColor colorWithWhite:WHITE alpha:1.0f]

    #define kColorFromRGB_A(RGBValue,ALPHA) [UIColor colorWithRed:((float)((RGBValue & 0xFF0000) >> 16)) /255.0 green:((float)((RGBValue & 0xFF00) >> 8)) /255.0 blue:((float)(RGBValue & 0xFF)) /255.0 alpha:ALPHA]

    #define kColorFromRGB(RGBValue) kColorFromRGB_A(RGBValue,1.0f)

    #define kRandomColor kColorWithRGB_A(arc4random()%256/255.0, arc4random()%256/255.0, arc4random()%256/255.0, 1.0f)

    #define kInt(STR) [STR intValue]

    #define kLongLong(STR) [STR longLongValue]

    #define kInteger(STR) [STR integerValue]

    #define kFloat(STR) [STR floatValue]

    #define kDouble(STR) [STR doubleValue]

    #define kBool(STR) [STR boolValue]

    #define kSTR(FORMAT,VALUE) [NSString stringWithFormat:FORMAT,VALUE]

    #define kSTRFormat(FORMAT,STR) [NSString stringWithFormat:FORMAT,kDouble(STR)]

    #define kAngle(ANGLE) ANGLE*M_PI/180.0

    #define kRadians(RADIAN) (180.0 * RADIAN / M_PI)

    #define kCurrentSystemVersion [[[UIDevice currentDevice]systemVersion]floatValue]

    #define IOS_VERSION_7_OR_LATER ((kCurrentSystemVersion >= 7.0)?(YES):(NO))

    #define IOS_VERSION_8_OR_LATER ((kCurrentSystemVersion >= 8.0)?(YES):(NO))

    #define IOS_VERSION_9_OR_LATER ((kCurrentSystemVersion >= 9.0)?(YES):(NO))

    #define IOS_VERSION_10_OR_LATER ((kCurrentSystemVersion >= 10.0)?(YES):(NO))

    #define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

    #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)

    #define IS_RETINA ([[UIScreen mainScreen]scale] >= 2.0)

    #define kCurrentLanguage [[NSLocale preferredLanguages]objectAtIndex:0]

    #define kBACK_GCD(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)

    #define kMAIN_GCD(block) dispatch_async(dispatch_get_main_queue(), block)

    #define kPickerImage(INFO) INFO[@"UIImagePickerControllerOriginalImage"]

    #define kAppName(NAME) CFBundleDisplayName = NAME

    还有什么常用的可以一起探讨哦!

    相关文章

      网友评论

          本文标题:一些常用的宏定义

          本文链接:https://www.haomeiwen.com/subject/gcengttx.html