ColorMacro.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // ColorMarcro.h
  3. // CommonLibrary
  4. //
  5. // Created by Alexi on 13-10-23.
  6. // Copyright (c) 2013年 ywchen. All rights reserved.
  7. //
  8. #ifndef CommonLibrary_ColorMarcro_h
  9. #define CommonLibrary_ColorMarcro_h
  10. #import "UIColor+MLPFlatColors.h"
  11. // 取色值相关的方法
  12. #define RGB(r,g,b) [UIColor colorWithRed:(r)/255.f \
  13. green:(g)/255.f \
  14. blue:(b)/255.f \
  15. alpha:1.f]
  16. #define RGBA(r,g,b,a) [UIColor colorWithRed:(r)/255.f \
  17. green:(g)/255.f \
  18. blue:(b)/255.f \
  19. alpha:(a)]
  20. #define RGBOF(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
  21. green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
  22. blue:((float)(rgbValue & 0xFF))/255.0 \
  23. alpha:1.0]
  24. #define RGBA_OF(rgbValue) [UIColor colorWithRed:((float)(((rgbValue) & 0xFF000000) >> 24))/255.0 \
  25. green:((float)(((rgbValue) & 0x00FF0000) >> 16))/255.0 \
  26. blue:((float)(rgbValue & 0x0000FF00) >> 8)/255.0 \
  27. alpha:((float)(rgbValue & 0x000000FF))/255.0]
  28. #define RGBAOF(v, a) [UIColor colorWithRed:((float)(((v) & 0xFF0000) >> 16))/255.0 \
  29. green:((float)(((v) & 0x00FF00) >> 8))/255.0 \
  30. blue:((float)(v & 0x0000FF))/255.0 \
  31. alpha:a]
  32. // 定义通用颜色
  33. #define kBlackColor [UIColor blackColor]
  34. #define kDarkGrayColor [UIColor darkGrayColor]
  35. #define kLightGrayColor [UIColor lightGrayColor]
  36. #define kWhiteColor [UIColor whiteColor]
  37. #define kGrayColor [UIColor grayColor]
  38. #define kRedColor [UIColor redColor]
  39. #define kGreenColor [UIColor greenColor]
  40. #define kBlueColor [UIColor blueColor]
  41. #define kCyanColor [UIColor cyanColor]
  42. #define kYellowColor [UIColor yellowColor]
  43. #define kMagentaColor [UIColor magentaColor]
  44. #define kOrangeColor [UIColor orangeColor]
  45. #define kPurpleColor [UIColor purpleColor]
  46. #define kClearColor [UIColor clearColor]
  47. #define kRandomFlatColor [UIColor randomFlatColor]
  48. #endif