Last active
August 29, 2015 14:20
-
-
Save algal/57e5628a03d2c0496034 to your computer and use it in GitHub Desktop.
UIColor from hex, and hex is a number dammit.
This file contains hidden or 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 | |
{ | |
convenience init(RGBValue:UInt32) | |
{ | |
let red = (RGBValue & 0xFF0000) >> 16 | |
let green = (RGBValue & 0x00FF00) >> 8 | |
let blue = (RGBValue & 0x0000FF) >> 0 | |
self.init(red:CGFloat(red)/255.0,green:CGFloat(green)/255.0,blue:CGFloat(blue)/255.0,alpha:CGFloat(1.0)) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment