Transform hex color to objective-c color.

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

This is exactly what I was looking for since I come from web development

Copy this code and paste it in your HTML
  1. //If you come from a web development background, you're probably more used to hex color //strings. Put this macro at the top of your .m file, after the imports
  3. #define UIColorFromRGB(rgbValue) [UIColor \
  4. colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
  5. green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
  6. blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
  8. //Now you can simply write
  9. cell.textColor = UIColorFromRGB(0xFF3366);


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.