Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
extension UIColor {
func shadeColor(factor: CGFloat) -> UIColor {
var r: CGFloat = 0
var g: CGFloat = 0
var b: CGFloat = 0
var a: CGFloat = 0
var t: CGFloat = factor < 0 ? 0 : 1
var p: CGFloat = factor < 0 ? -factor : factor
getRed(&r, green: &g, blue: &b, alpha: &a)
r = (t-r)*p+r
g = (t-g)*p+g
b = (t-b)*p+b
return UIColor(red: r, green: g, blue: b, alpha: a)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.