Skip to content

Instantly share code, notes, and snippets.

@algal
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save algal/57e5628a03d2c0496034 to your computer and use it in GitHub Desktop.
Save algal/57e5628a03d2c0496034 to your computer and use it in GitHub Desktop.
UIColor from hex, and hex is a number dammit.
extension UIColor
{
convenience init(RGBValue:UInt32)
{
let red = (RGBValue & 0xFF0000) >> 16
let green = (RGBValue & 0x00FF00) >> 8
let blue = (RGBValue & 0x0000FF) >> 0
self.init(red:CGFloat(red)/255.0,green:CGFloat(green)/255.0,blue:CGFloat(blue)/255.0,alpha:CGFloat(1.0))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment