Created
December 29, 2014 14:12
-
-
Save axelrivera/a7036e30ce92f6928e44 to your computer and use it in GitHub Desktop.
UIColor+Hex
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(hex: NSInteger) { | |
self.init(hex: hex, alpha: 1.0) | |
} | |
convenience init (hex: NSInteger, alpha: CGFloat) { | |
let red = CGFloat((hex & 0xFF0000) >> 16) / 255.0 | |
let green = CGFloat((hex & 0xFF00) >> 8) / 255.0 | |
let blue = CGFloat((hex & 0xFF)) / 255.0 | |
self.init(red: red, green: green, blue: blue, alpha: alpha) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment