Skip to content

Instantly share code, notes, and snippets.

@JoeFerrucci
Created July 27, 2016 21:04
Show Gist options
  • Save JoeFerrucci/89a1dc5bbeaae57d607a56ddefa86a68 to your computer and use it in GitHub Desktop.
Save JoeFerrucci/89a1dc5bbeaae57d607a56ddefa86a68 to your computer and use it in GitHub Desktop.
Easy UIColors using hex values, no more slower string manipulation.
extension UIColor {
convenience init(hex: Int) {
self.init(red: CGFloat((hex & 0xFF0000) >> 16) / 255.0,
green: CGFloat((hex & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(hex & 0x0000FF) / 255.0,
alpha: 1.0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment