Skip to content

Instantly share code, notes, and snippets.

@0xc010d
Created August 14, 2011 14:35
Show Gist options
  • Save 0xc010d/1144925 to your computer and use it in GitHub Desktop.
Save 0xc010d/1144925 to your computer and use it in GitHub Desktop.
//UIColor+Defined.h
typedef uint32_t DColor;
+ (UIColor *)colorWithDefinedColor:(DColor)dColor;
+ (UIColor *)colorWithDefinedColor:(DColor)dColor alpha:(CGFloat)alpha;
//UIColor+Defined.m
+ (UIColor *)colorWithDefinedColor:(DColor)dColor {
return [self colorWithDefinedColor:dColor alpha:1.0f];
}
+ (UIColor *)colorWithDefinedColor:(DColor)dColor alpha:(CGFloat)alpha {
CGFloat blue = (dColor & 0xff) / 255.0f;
CGFloat green = (dColor >> 8 & 0xff) / 255.0f;
CGFloat red = (dColor >> 16 & 0xff) / 255.0f;
return [self colorWithRed:red green:green blue:blue alpha:alpha];
}
//Constants.h
#import "UIColor+Defined.h"
extern DColor const myColor;
//Constants.m
DColor const myColor = 0xcccccc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment