Created
December 12, 2017 09:54
-
-
Save StevenMasini/c0eca227576e74723d2469781832d834 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { | |
/// Init a UIColor base on the color hexadecimal value | |
/// | |
/// - Parameters: | |
/// - hex: Hexadecimal code of the color | |
/// - alpha: Alpha opacity, between 0 and 1 | |
public convenience init(hex: UInt, alpha: CGFloat) { | |
self.init( | |
red: CGFloat((hex & 0xFF0000) >> 16) / 255.0, | |
green: CGFloat((hex & 0x00FF00) >> 8) / 255.0, | |
blue: CGFloat(hex & 0x0000FF) / 255.0, | |
alpha: alpha | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment