Skip to content

Instantly share code, notes, and snippets.

@soffes
Created June 6, 2016 23:48
Show Gist options
  • Save soffes/68d355e828cb502f75c3b8f989962958 to your computer and use it in GitHub Desktop.
Save soffes/68d355e828cb502f75c3b8f989962958 to your computer and use it in GitHub Desktop.
Desaturate a UIColor
import UIKit
extension UIColor {
var desaturated: UIColor {
var hue: CGFloat = 0
var brightness: CGFloat = 0
var alpha: CGFloat = 0
getHue(&hue, saturation: nil, brightness: &brightness, alpha: &alpha)
return self.dynamicType.init(hue: hue, saturation: 0, brightness: brightness, alpha: alpha)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment