Created
July 2, 2014 23:16
-
-
Save 0xc010d/670517342b389a82082f to your computer and use it in GitHub Desktop.
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
import UIKit | |
typealias ColorDef = UInt32 | |
extension UIColor { | |
convenience init(_ colorDef: ColorDef) { | |
self.init(colorDef: colorDef) | |
} | |
convenience init(colorDef: ColorDef) { | |
self.init(colorDef: colorDef, alpha: 1.0) | |
} | |
convenience init(colorDef: ColorDef, alpha: CGFloat) { | |
let blue = CGFloat(colorDef & 0xff) / CGFloat(255) | |
let green = CGFloat(colorDef >> 8 & 0xff) / CGFloat(255) | |
let red = CGFloat(colorDef >> 16 & 0xff) / CGFloat(255) | |
self.init(red: red, green: green, blue: blue, alpha: alpha) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment