Created
July 2, 2014 17:58
-
-
Save mtrovilho/d334462e5b5b7511f811 to your computer and use it in GitHub Desktop.
UIColor with 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: UInt32) { | |
var r: CGFloat = (CGFloat((hex & 0xFF0000) >> 16) / 255.0) | |
var g: CGFloat = (CGFloat((hex & 0x00FF00) >> 8) / 255.0) | |
var b: CGFloat = (CGFloat (hex & 0x0000FF) / 255.0) | |
self.init(red: r, green: g, blue: b, alpha: 1.0) | |
} | |
} | |
let green = UIColor(hex: 0x00A859) | |
let yellow = UIColor(hex: 0xFFCC29) | |
let blue = UIColor(hex: 0x3E4095) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment