Skip to content

Instantly share code, notes, and snippets.

@leah
Created January 17, 2011 20:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save leah/783376 to your computer and use it in GitHub Desktop.
Save leah/783376 to your computer and use it in GitHub Desktop.
//
// UIColor+HexColor.h
//
// Created by Leah Culver on 11/9/10.
//
#import <UIKit/UIKit.h>
@interface UIColor (HexColor)
+ (UIColor *)hexColor:(int)hexString;
@end
//
// UIColor+HexColor.m
//
// Created by Leah Culver on 11/9/10.
//
#import "UIColor+HexColor.h"
@implementation UIColor (HexColor)
+ (UIColor *)hexColor:(int)hex {
float red = ((float)((hex & 0xFF0000) >> 16))/255.0;
float green = ((float)((hex & 0xFF00) >> 8))/255.0;
float blue = ((float)(hex & 0xFF))/255.0;
return [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment