Created
June 6, 2016 23:48
-
-
Save soffes/68d355e828cb502f75c3b8f989962958 to your computer and use it in GitHub Desktop.
Desaturate a UIColor
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
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