Created
March 19, 2018 13:07
-
-
Save Anatoli-Petrosyants/d1bc9d2b5d71f0137e85440647ecc341 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
| public extension UIColor { | |
| convenience init(hex: Int, alpha: Double = 1.0) { | |
| let r = CGFloat((hex & 0xFF0000) >> 16) / 255.0 | |
| let g = CGFloat((hex & 0x00FF00) >> 8) / 255.0 | |
| let b = CGFloat(hex & 0x0000FF) / 255.0 | |
| self.init(red: r, green: g, blue: b, alpha: CGFloat(alpha)) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment