Skip to content

Instantly share code, notes, and snippets.

@axelrivera
Created December 29, 2014 14:12
Show Gist options
  • Save axelrivera/a7036e30ce92f6928e44 to your computer and use it in GitHub Desktop.
Save axelrivera/a7036e30ce92f6928e44 to your computer and use it in GitHub Desktop.
UIColor+Hex
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