Skip to content

Instantly share code, notes, and snippets.

@idrisr
Created July 25, 2016 19:31
Show Gist options
  • Save idrisr/797d93e7332504d31b79fec7cf68bbe6 to your computer and use it in GitHub Desktop.
Save idrisr/797d93e7332504d31b79fec7cf68bbe6 to your computer and use it in GitHub Desktop.
public convenience init (_ rgbHex: UInt, alpha: CGFloat = 1.0) {
let rawRed = Double((rgbHex & 0xFF0000) >> 16) / 255.0
let rawGreen = Double((rgbHex & 0x00FF00) >> 8 ) / 255.0
let rawBlue = Double((rgbHex & 0x0000FF) ) / 255.0
self.init(red: CGFloat(rawRed), green: CGFloat(rawGreen), blue: CGFloat(rawBlue), alpha: alpha)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment