Created
October 23, 2014 06:01
-
-
Save windless/0169268ccc1fe47fc696 to your computer and use it in GitHub Desktop.
UIColor hexColor
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 { | |
class func hexColor(hex: Int, alpha: Double = 1) -> UIColor { | |
let red = Double((hex & 0xFF0000) >> 16) / 255.0 | |
let green = Double((hex & 0xFF00) >> 8) / 255.0 | |
let blue = Double((hex & 0xFF)) / 255.0 | |
return UIColor(red: CGFloat(red), green: CGFloat(green), blue: CGFloat(blue), alpha: CGFloat(alpha) ) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment