Skip to content

Instantly share code, notes, and snippets.

@nuclearghost
Last active August 29, 2015 14:06
Show Gist options
  • Save nuclearghost/b8c20c9390e00d5e0612 to your computer and use it in GitHub Desktop.
Save nuclearghost/b8c20c9390e00d5e0612 to your computer and use it in GitHub Desktop.
Create a UIColor from a Hex Value
func UIColorFromRGB(rgbValue: UInt) -> UIColor {
return UIColor(
red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
alpha: CGFloat(1.0)
)
}
//Call with UIColorFromRGB(0x209624)
//From SO http://stackoverflow.com/questions/24074257/how-to-use-uicolorfromrgb-value-in-swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment