Skip to content

Instantly share code, notes, and snippets.

@quangtqag
Created January 19, 2016 03:59
Show Gist options
  • Save quangtqag/52cea206f52b0ea637cd to your computer and use it in GitHub Desktop.
Save quangtqag/52cea206f52b0ea637cd to your computer and use it in GitHub Desktop.
extension UIColor {
class func mainTextColor() -> UIColor { return UIColor(hex: 0x000000) }
class func subTextColor() -> UIColor { return UIColor(hex: 0x656565) }
}
extension UIColor {
convenience init(red: Int, green: Int, blue: Int) {
assert(red >= 0 && red <= 255, "Invalid red component")
assert(green >= 0 && green <= 255, "Invalid green component")
assert(blue >= 0 && blue <= 255, "Invalid blue component")
self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1.0)
}
convenience init(hex:Int) {
self.init(red:(hex >> 16) & 0xff, green:(hex >> 8) & 0xff, blue:hex & 0xff)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment