Author: Dids Language: objc
Description: Not specified Timestamp: 2013-05-13 07:25:23 +0000
View raw paste Reply
  1. + (UIColor *)colorWithHex:(NSString *)str
  2. {
  3.     const char *cStr = [str cStringUsingEncoding:NSASCIIStringEncoding];
  4.    
  5.     long x = strtol(cStr+1, NULL, 16);
  6.    
  7.     return [App colorWithFullHex:x];
  8. }
  9.  
  10. + (UIColor *)colorWithFullHex:(UInt32)col
  11. {
  12.     unsigned char r, g, b;
  13.    
  14.     b = col & 0xFF;
  15.     g = (col >> 8) & 0xFF;
  16.     r = (col >> 16) & 0xFF;
  17.    
  18.     return [UIColor colorWithRed:(float)r/255.0f green:(float)g/255.0f blue:(float)b/255.0f alpha:1];
  19. }
View raw paste Reply