Skip to content

Instantly share code, notes, and snippets.

@kazuhiro4949
Created May 4, 2016 06:37
Show Gist options
  • Save kazuhiro4949/e9791aa714c6970690d393e2ade4a11f to your computer and use it in GitHub Desktop.
Save kazuhiro4949/e9791aa714c6970690d393e2ade4a11f to your computer and use it in GitHub Desktop.
convert rgb to UIColor object
extension UIColor {
/**
convert rgb to UIColor object
*/
class func color(color: UInt32, alpha : CGFloat = 1.0) -> UIColor {
let r = CGFloat((color & 0xFF0000) >> 16) / 255.0
let g = CGFloat((color & 0x00FF00) >> 8) / 255.0
let b = CGFloat(color & 0x0000FF) / 255.0
return UIColor(red:r,green:g,blue:b,alpha:alpha)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment