Skip to content

Instantly share code, notes, and snippets.

@bananafish911
Created October 15, 2016 09:22
Show Gist options
  • Save bananafish911/61694613b9dfe90beb71bc99d4a5a80b to your computer and use it in GitHub Desktop.
Save bananafish911/61694613b9dfe90beb71bc99d4a5a80b to your computer and use it in GitHub Desktop.
extension UIColor {
/// Format: 0xFFAACC
convenience init(hex: Int) {
let components = (
R: CGFloat((hex >> 16) & 0xff) / 255,
G: CGFloat((hex >> 08) & 0xff) / 255,
B: CGFloat((hex >> 00) & 0xff) / 255
)
self.init(red: components.R, green: components.G, blue: components.B, alpha: 1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment