Skip to content

Instantly share code, notes, and snippets.

@alexbosworth
Created September 8, 2015 04:01
Show Gist options
  • Save alexbosworth/f673fc6f24c49b010fa5 to your computer and use it in GitHub Desktop.
Save alexbosworth/f673fc6f24c49b010fa5 to your computer and use it in GitHub Desktop.
convert a ui color to grayscale
var (hue, saturation, brightness, alpha) = (CGFloat(0.0), CGFloat(0.0), CGFloat(0.0), CGFloat(0.0))
let originalColor = UIColor.redColor()
if originalColor.getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: &alpha) {
let grayscale = UIColor(hue: hue, saturation: 0, brightness: brightness, alpha: alpha)
}
@phuna
Copy link

phuna commented Mar 25, 2016

Thank you for sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment