Macro to use HEX color


/ Published in: Objective C
Save to your folder(s)

OBJC macro to use HEX color values to init UIColor objects


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.