Created
May 4, 2016 06:37
-
-
Save kazuhiro4949/e9791aa714c6970690d393e2ade4a11f to your computer and use it in GitHub Desktop.
convert rgb to UIColor object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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