Created
April 29, 2015 09:39
-
-
Save lbrndnr/705946cb937fadeebca4 to your computer and use it in GitHub Desktop.
UIColor to init them using hex values: UIColor(0x8046A2)
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 { | |
convenience init(_ hexValue: Int) { | |
let r = (hexValue & 0xFF0000) >> 16 | |
let g = (hexValue & 0x00FF00) >> 8 | |
let b = hexValue & 0x0000FF | |
self.init(red: CGFloat(r)/255, green: CGFloat(g)/255, blue: CGFloat(b)/255, alpha: 1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@a2 I wasn't using this with objc really but that would make sense otherwise :)