Posted By

Gretzki on 05/16/12


Tagged

space macro color conversion RGB


Versions (?)

Macro to use HEX color


 / Published in: Objective C
 

OBJC macro to use HEX color values to init UIColor objects

  1. //RGB color macro
  2. #define UIColorFromRGB(rgbValue) [UIColor \
  3. colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
  4. green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
  5. blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
  6.  
  7. //RGB color macro with alpha
  8. #define UIColorFromRGBWithAlpha(rgbValue,a) [UIColor \
  9. colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
  10. green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
  11. blue:((float)(rgbValue & 0xFF))/255.0 alpha:a]

Report this snippet  

You need to login to post a comment.