Skip to content

Instantly share code, notes, and snippets.

@zummenix
Created August 8, 2016 07:21
Show Gist options
  • Save zummenix/511fabc94f2dc6fbb2fe4cb6c002bc8d to your computer and use it in GitHub Desktop.
Save zummenix/511fabc94f2dc6fbb2fe4cb6c002bc8d to your computer and use it in GitHub Desktop.
Allows to change brightness of an UIColor.
private extension UIColor {
func addedBrightness(value: CGFloat) -> UIColor {
var cs: (hue: CGFloat, saturation: CGFloat, brightness: CGFloat, alpha: CGFloat) = (0.0, 0.0, 0.0, 0.0)
self.getHue(&cs.hue, saturation: &cs.saturation, brightness: &cs.brightness, alpha: &cs.alpha)
return UIColor(hue: cs.hue, saturation: cs.saturation, brightness: cs.brightness + value, alpha: cs.alpha)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment