Skip to content

Instantly share code, notes, and snippets.

@jeffcdavis
Created February 18, 2017 02:30
Show Gist options
  • Save jeffcdavis/63758071393701cbbecd940b8d385e1e to your computer and use it in GitHub Desktop.
Save jeffcdavis/63758071393701cbbecd940b8d385e1e to your computer and use it in GitHub Desktop.
func UIColorFromHex(rgbValue:UInt32, alpha:Double=1.0)->UIColor {
let red = CGFloat((rgbValue & 0xFF0000) >> 16)/256.0
let green = CGFloat((rgbValue & 0xFF00) >> 8)/256.0
let blue = CGFloat(rgbValue & 0xFF)/256.0
return UIColor(red:red, green:green, blue:blue, alpha:CGFloat(alpha))
}
view.backgroundColor = UIColorFromHex(0x323232,alpha: 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment